This video demonstrates solving a competitive programming problem where a character (Takashi) must escape a labyrinth grid while avoiding K guard robots that move deterministically toward Takashi's position. The solution uses multi-source BFS to track Takashi's position and all guard positions simultaneously, with guards moving to minimize Manhattan distance to Takashi. The algorithm checks if Takashi can reach the exit before being caught, handling the turn-based movement sequence where Takashi moves first, followed by capture and escape checks, then guard movements. The constraints (N, M ≤ 8) allow for this approach despite the exponential state space.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Hard thinking Live Practicing AtCoder Weekday Contest 76Added:
Hi. Hi. Hi.
I'm live right audible.
Okay. Today we have two options.
Should should now let me start with add folder and then we'll move to get we have audience by forget it likewise it share my screen cool this is 76 to edit the title 76 I remove this beta Anyone know how can how we can use SEO to get a better reach?
Say SEO setting right which one this is hashtags see.
Okay.
Let me start. Yeah, we have five minutes to decide. Let's go.
I have a code of light on the chat side by side.
Okay.
The part is connected.
Yeah. And what about focus mode?
Yeah. On.
And we want hello. Yeah.
Hey Rich, how are you?
I'm good. I'm good. After so long after long, right? It's been a week. I haven't did any stream.
I should try lit code virtual or at coder contest two option no actually I I it's not I went for a trip this weekend that's why I haven't participated in a lit code so I have two pending lit code I can do that virtual contest today or we can go with a usual coder contest.
I did the late code one. Not good. I want to do more at coder.
Yeah, trip was nice.
It actually tested the patience.
What should we can go? Red code or red code? Let me create a poll. How you can create a poll? Start a poll.
Uh he what we scan coco headquarter start poll there's one person and I created a poll I don't know why I can lit code if you want to do there are little interesting My other ID is to vote for red adder. Okay, we can go with add coder then there's no yeah what we can do is let me start with the add coder and yeah then we can try hard question yeah that that's fine because the medium and easy are I'm used to with that question and I'm able to solve in contest also uh okay I think contest start in 2 minute in add quarter also we can follow the similar pattern Instead of going A B C D, we can go for D CBA. What do you think? Can we go in reverse order?
Okay, let's go in a reverse order. This is interesting.
We go in reverse order.
We can actually try code on reverse order. That's that interesting.
Let me add egg is hard think hard because we don't know we able to solve or not think thinking oh someone voted for at there's one person who has actually voted for late code yeah we can touch few problems of late code also especially We fill the last two, third and four problem.
Okay, we have 1 minute to go for head at quarter contest. That's fine.
So actually, thanks you. It's I feel you you created a virtual viewers for me.
Okay, let's go.
Let me open the record code also.
Ah, lucky 10 points will be.
Okay, so we'll go in the reverse order here and we'll go with fourth first D. Oh my god, it's an essay. It's not a question.
This is a essay. We have it's a two scroll question. This is one scroll. This is second scroll and looking at the constraint I can definitely say this is a bit mass question.
So we have to explore all the that is what my assumption is looking at this constraint is n just goes to 8 m just goes to 8 k okay oh but I got unlucky question here I'm lucky but the question is unlucky I have to read the entire story just to understand the drugs I had not waste the The cashi is trapped. Okay. In n + n grid shape. What is this labyrinth?
Labyrinth. What does that mean?
Actually, what the hell it is? What is this? Oh, maze.
Oh, I don't know. We have This is what we call is maze, right? But the real name is Labberinthos.
This is interesting lab. How to pronounce it?
How to pronounce?
How are I want to know how to pronounce this word labyrinth, right?
Labyrinth.
>> Labyrinth. Yeah, correct.
Gift. Thanks.
Labithm.
Labon. Labathon. Yeah, that's all. So the class is trapped in N cross M grid shape lab. Each cell create represent.
It says a dot or a wall. Passage or a wall. Okay. Okay. Both rows and columns are number from one. Okay, it's a one with indressing and yeah these are their exit. We can move up, down, left and right.
Okay, the cash is currently is this and try to exit at this. Okay, there are K guard robot.
Oh, this is a multi source. Now this the K guard for patrolling the labyrinth the E guard initi okay for each robot we have a different starting position each guard robot movement is determined or deterministically determined based on a based solely on takash's position okay according to the movement rule described below so this is how the robots will move.
Uh Takashi and the guard group would repeat turn as follow the first turn follow. Okay. No capture check is performed at the start of the game.
Okay. Before the step one or off. Okay.
Each turn proceed in the following order. Okay. The cash is moment. This Takashi is choose to either move one cell to existent cell in one of the four direction or stays on his current cell.
Okay. He can't move outside the wall.
Okay. Capture check one. After Takash is moved, if Takashi is on the same cell as the guard robot, Takash is caught and escape failed. Okay.
In this case, the remaining step of ST is not executed. Okay. Escape check. If Takashi was not kept caught in the capture check one and Takasi is in exit.
Okay, then we have successfully escaped.
This is moment and robot guard robot movement. If neither escape subscript uh escape success nor escape fail has occurred, all guard robots simultaneously move one step.
Moment rule described below. Where is the moment rule? Oh, this is the moment rule. Okay. Each robot determine its destination independently of the other robot. Multiple robot are allowed to occupy the same cell. Okay. And there is a capture check to after guard robot move. If the cash is on the same cell, okay, for now it's a story. Story you guys understand, right? This is the story. We have a maze and not let's not call it maze. Let's call it real name labyrinth.
There is a labyrinth of n cross m. The cash is at some coordinate. All the guard robot is at some coordinate. The cashi moves one step and guards also move accordingly and this is the rule where the guard move. If the car see caught or or not accepted that is escape that is what we have to find out right each guard robot either move one cell ex cell of the four direction or it can't move to wall cell or outside okay or stays on the current cell that's fine each guard robot's destination is to deter destination is determine it follow first enumerate the movement enumerate The movement candidate. Okay.
The candidate are move up, left, right.
Okay. All the four direction. The destination is within the grid and and is a spaces as well as staying on the current cell at most five candidate.
Okay, we have five candidate. We can move all the cell or we can at the we can we can stay at the current position.
For each candidate, compute the Manhattan distance from the robot position after the movement of Takash.
Okay. After the move to Tai. Okay. So, I think we have robot will move one step closer to Takahash's position. Yeah.
Among the candidates the one minimize the Manhattan distance is selected. If a multiple candidate minimum manhattan distance then we have to follow this priority up left or state. Okay, we got the question.
Uh, question is clear, right?
Question is clear, right? I should describe one more time.
Out would be whether Takashi can ask escape when he act optimally.
Yep. So question is clear. when he had optimally uh acting optimally means there exist a sequence of action that lead to escape success. He choose such a sequence of all. So what we can do here guys? What we can do here?
I gave you hint right?
V N is this M is this. That means total total number of cell maximum can grow up to 8 + 8 that is 64.
That is 64. And 2 to the^ 64 is around uh that is what? Let it check. 2 ^ 64 is around.
Oh, it's too big. Then what we have to do is we have to try meet in a middle.
This is another optimization.
Let's break it. So what we'll do is anyway we want all the see constraint is small. What we can there is a better option no doubt but we know constraint is small. We can apply brute force but smart brute force not a brute force while brute force you guys get it right no see let me try a few options we can actually apply brute force here but a smart brute force how see just break this uh we anyway we want all possibility right so what we can do is we'll create 2 to the^ 30 Okay. Wait, wait, wait. No, no, no. What I'm what I what I'm thinking is can we break into two parts? 2 to the^ 30 and another is 2 to the power 30. 2 to the power 32 is fine, right?
Uh it's also 1 2 1 2 3 4 5 6 7 8 9.
So 9. No, we can't even apply to 32.
Yeah, no brute force now.
forgot about bit force. Okay. So this is how we can eliminate the ideas. Now what option we will have?
Uh we will have let's say this is the cach's position and we are in this grid.
What we can do is we can uh use multisource BFS. That's the only option left in my mind right now. Right. What we can do here is we'll start a multisource DFS and yeah in each move we'll check the describe scenario here right this is what we can do is if the cashi reached the escape that means successfully escape the grid if it not it failed to escape this idea seems reasonable Right.
Why it's still big? We can apply multisource BFS, right?
BF is what's the time complexity just uh how multissource multissource I mean is uh yeah multissource works right because in a no I mean two okay yeah 2 to the^ 36 is actually big yeah we we are not going with optimization Now, so what we can do is we'll apply multisource BFS here and yeah that's the that's the potential solution I can think of right now and multisource BFS is optimal because see let's say we are at some cell if someone already visited this cell that means that guard is no like let's say there's two guard right before this guard this guard enter this cell then the uh synchron Honestly, if you think there's no use of this guard, right? If this guard is itself and if this guard caught the takashi, that means this guard will also uh there's less chances that this guard there's a less chances this guard will not catch because this is the nearest guard. If this guard enter this cell uh first then this the I'm not able to put it in a generalized form. My point is if we are at some point how like how brute force is seem optimal to me. See let's say this is the cell and we have two guards guard one and guard two and takashi is here.
So if we compute for this guard if this gu let's say there's two possibility right this guard can catch the takashi this guard will not catch the takashi.
Yeah. So my point is if this guard itself caught the takashi that means for this guard also it may be caught the tagashi right it may be caught the tagashi if this guard is unable to catch the takashi that means we surely say this guard won't catch the tagashi so yeah so we'll apply multissource bfs is okay let's time we'll see we'll not waste much time here then it's visible right for the input we have n m and k the cast is position the cash is escape position and k points oh [ __ ] [ __ ] [ __ ] I haven't read the question carefully that wins what's this c1 to cn I have no idea Yeah. What's this C1 to CN?
What is this doing here? What are this things?
Oh, what are this point? CN represent the information I throw from the top. The J character of CI represent Haha. It's input.
It's input grid actually. Okay.
Okay. Okay. Okay.
This, this, this.
So, we have N, M, and K.
F.
Then we have source SX, SY, SX, SY. Okay.
Then we have this destination gx gy gx gy okay we are s so we are destination then all the guard robot coordinate vector of int.
So actually let me make so we are applying a multi source BFS here uh let me take the input first that's card's position and it's a P zero I less than K and I ++ X Y let's say X Why just feel bored, right? Do do you guys feel bored? Cuz I'm feeling bored.
There's no music.
There's no some It's a used coding, right? If you guys feel bored, let me know. I will play some music. Then I will get the copyright.
We'll try some copyright free music.
X comma Y.
Okay, we'll take the input.
My brain is not fluff. Oh, this is an interesting word.
Fluffford.
Fluff. Fluffford.
How to pronounce this? It's Fluffford.
Right. I'm learning actually vocabularies lie down or fuse as a young bird on. Oh my god. So where did you learn this word? It meaning is also I'm unable to understand it meaning milk.
Can you explain me what this word mean?
Something having a very light soft and fontic consistency or appearance.
something of little substances or consequence escape lights or it has a deep meaning.
Okay. Okay. Okay. So we have uh now we have to take the input of a grid also vector of string grid n + see in no thoughts in brain. Okay.
three in grid of I. Okay, so we have done with all the inputs.
All the [ __ ] inputs.
Okay, guys. Guys, this just simply tell but aren't able to understand what's going on. Even if able to understand the un okay just let me know I will make you understand uh see till now we I have just taken a input this is fine right there is a word called there is a word there's a concept in a graph that we call as a multisource multisource BFS or BFS doesn't mean multisource traversal so what that mean is let's say what multisource Traveler means is let's say we have a grid see this is a D question right so it needs some better algorithm so this is one of them no worry let me tell you the overview what is multissource like means multisource means in let's say you have to reach from this corner to this corner right what we'll do is we we just run any travels algorithm and we'll see there's a path or not If we have that means we have one source and one destination right that is one let me write it down one source and one destination this is the ideal traversal necessary condition right now instead of one source did you get it this point we have one source and one destination and we perform in algorithm and we'll check ah dra algorithm that yeah you can say d algorithm This is just a travel algorithm that tell you the minimum time or minimum distance to reach from source to destination. That's the desk algorithm.
So this is fine right? Then what we can do instead of one source let's say there are three person in the grid. One person is here the person is here and third person somewhere here. Now this now the question asks like the question can frame like which person will reach which among these three which person will reach earliest to this destination.
So instead of performing uh performing three singles uh this one source to destination what we can do is let's say we perform we have three source now and each has a one destination right so anything greater than one source we call it has a multisource travel server we are doing a single source will perform similar pattern instead of one start we have three different starts that's the only difference here yeah so what we'll do is so why why I'm why this makes sense here because see we have one source the cash is standing here and we have k different source this uh uh this guard is standing here right then each will move at a time multisource going to and multi okay clear thanks it's clear right so why this makes sense in this question is because takashi is the one source and all the guard is also one source for takashi this this uh GR and GC is the destination and for this guard Takashi's coordinate is the destination right so yeah I'm forot should be mentioned here in one likewise there's a one like you see like one source three source and source likewise we have destination also 1d one destination two destination three destination it's not doing thanks but I'll take as a compliment thanks now I have I told you right I went a trip that trip actually tested lots of things so whatever I get it will accept it. That's what I learned from that.
Okay. So, let me code it out. The code is also I'm not sure how long it will take but I'll try to explain. It's a single part of the code. Right. So, what we need? We need firstly we need to create all the Q Q contain all the source point Q right it's a pair of int comma int comma int actually we need to create a here this is also not new but right we need three things at each point how much time because they they're asking right the cash will escape or not.
So it doesn't mean a minimum it just need it can escape or not.
Hey Shivam after long is actually my friend where I work uh in my B tech fourth year. Hi SH, how are you? Long time a now bro got his training arc from I created my own training arc. I haven't it's not a gift.
So what we'll do here is we'll perform a multissource BFS that yeah and actually time doesn't we don't have to track the third variable that is the time thanks bro I won't I I'm not like ready to see that you will join my stream but yeah thanks for joining that's another motivation See the coworker is joining the strings there. Okay, let me call it as Q.
So Q in the Q will maintain all the sources, right? The first source is first source is like the Takash is coordinate itself. Q dot push what uh S S X and S Y. So this is the takatus coordinate and also we have to push all the guard position X Y and the guard positions are in P right so it's currently we have 50/50 vote for L code and add coder after my mind won't able to catch up at coder code problems then we'll shift to late coder Then I have asked you right I'm tired and that's why I'm shifting late coder but that is not the actual reason I'm unable to solve the coder question anymore that's the actual reason I'm shifting to at late code right so what we'll do is q dot push x and y okay that's fine right and also we have to maintain the visit like coordinate is visited or Let's uh visit let's say n comma vector of int n comma 0. Cool.
Don't be lying. We just don't want to show us a smart you bringing this statements.
Okay. And all the source and one more thing uh let me create this vector uh somewhere here. So all the source we have to mark it as one. So visit of and it's a one with index right. So we have to create a one base grid here and okay or what we can do is we can create the entire question to a zero base. Yeah, that's the what what I'll do here is let me do x - and y - I got few messages being humble I'm not make do being humble do not make us feel dumb I know just can't prove it yet no comments No comments on this.
Okay. So, we have converted the coord the coordinates into zerobas indexing.
Let me convert this also zero base uh sx - sy - and the destination also one base. So let's create into S and G by minus min - okay right everything is zero business now this is this the car start this is the class destination and these are the coordinates of the guard coordinates that guard robot it's also in a zero index now cool so what we just need to do just mark as one that this is visited okay and What we'll do here is we again mark here visit of uh x, y.
Okay.
Now we'll start our multissource. See there's no difference between single source and multisource. There's only this is the only difference. Say in single source you don't need to run this for loop to mark or to capture the initial source for all the n minus one sources right that's it in multis source we just populate this Q with other sources also has a potential start that's the only right so what we'll do here is while Q is not empty okay what we'll do here is we'll take the auto X coordinate from the Q dot front and we'll pop out.
Okay. Now we have the first source like any of the potential is any right.
Yeah. So what we'll do here is we have a potential candidate from this potential candidate we have to check.
Oh one more thing how will track it is a takashi's coordinate or it is a guard coordinate right that is what we have to track if it is takash's coordinate then we have to per so did you guys remember we have two checks here right check and this check so to identify the coordinate that we got from this Q we need some indicator right it is takas coordinate or it is in guard accordingly. So that's why we have to we have to maintain the third thing third that's just the information extra information and it is tell us okay this is zero zero means it is a tasis coordinate and one means it's a guard coordinate yeah so did you guys get it x y and identity let's say identity let's not make it big variable name xy and Zed is just identity right. So now what we'll do is we'll check if zed is one that means this coordinate the xy coordinate is the takash's coordinate.
So what we'll check here if x is equal to g of x and then y is equal to g of y that means the cash is reached its destination right what we have to output is don't tell me minimum ah popping we have to tell the minimum turn also then we have to then we have to use this distance uh see we have to found we have to tell what is the minimum time takas will taken from its source to reach its destination. So we have to maintain one more thing instead of visit. So that's a trick. So visit with just marking 01 right. So instead of marking 01 what we'll do is we'll mark uh we'll store our visited array as our uh answer array like how much time takashi took from coordinate x to reach that coordinate y. Did you guys get this or I think I haven't Express my idea clearly here, right?
Just let me know like the thing the to answer this minimum what are they asking? So we we just need to convert our visited into our distance vector of vector and why that will help I will explain if you guys didn't get this point just let me know is otherwise I will proceed. So, so earlier what we are doing with this visited area, we just use this V element uh vector. If it is zero that means this that coordinate is not visited till now.
If it is one that means that coordinate is visited.
But now the question is asking what is the minimum time for the cashes to reach the destination. So instead of storing zero and one what I will do is I will store how many time let's how many step the cursor actually took. So what we'll do is we'll treat this vector visit as a let me mark distance. So that will not create ambiguity here distance right initially distance is zero.
We don't even need this.
Oh [ __ ] Yeah, we need we need two different I got it. Got it. Got it. I'm making some mistake here. We need two separate vectors. One is for distance and one is for uh one is no no let me think a while.
So we have two options now.
Distance vector of vector of 2D vector of distance and 2D vector of visit. We can actually make use of 2D vector of distance we don't need to create but that needs some optimization and code is also not clear if I try to explain with only one one right so for simplicity we can create two also there's one more guys zpaps hey bridge hope you brought better jokes than this chat it.
You don't get what you're trying to say.
But this is also another joke then.
Anyway, we need to keep track of distance, right?
For now, let me create a separate vector for distance also.
Distance. Okay.
Everything is minus one. See this is what I want to tell. If it is minus one that cell is not visited. Yeah. Yeah.
Yeah. You can use only distance vector and work is you can walk around distance and we'll mark distance as zero.
Okay. And distance as zero. Cool.
There's no more question, right?
>> Uh damn, how much time it took us to reach this point is 40 minutes.
So what we can do here is yeah if x is one it this is this interesting chat. Let me just cook more.
Can't wait to see what's the real name of what's the real name you guys. I really want to know. I don't want to know your real names but something.
Can't wait to see what green. Wait let me focus on my code first. So, what we'll do here is I got a call. Wait a minute.
Just a minute. Just a minute.
Live stream.
Okay.
So what we'll do here if it is takash is and this is the case then we'll check here one more thing this is a dash algorithm right so we can put one more check here instead of minus one what we'll do is 1 e 18 okay so what we'll do here is we'll Uh how we can get the distance? Wait wait wait wait wait. Uh here.
Oh we now we need to store one more thing here with the coordinate. How much time it took us to reach this coordinate?
Actually can we treat our takashes coordinate and guard coordinate same? Can we take these two things as a similar thing?
No. Right? Because if some guard reach what if the coordinate will get from our queue and it is at the destination point. How will bif for gate it is takashi's point? Takashi reached the destination point or guard is so we need some identifier there right? Yeah that is fine. So what we can do here is uh let make it double. This is fine. We need your pair also and int comma int.
So this is what we want. So theashi that means zero that means it's the cash's coordinate and the distance is initial zero.
Okay. And here I will make one means it's a guard coordinate and the current because it's standing at the same position right this YouTube algorithm like always there's a I don't know what algorithm they're running but I always bring the interesting person in my chat.
That would make me that won't make me feel sleepy. At least I I get some entertainment from there.
Did you guys actually learn right? I just have fun. I don't know what's the opinion.
So what I do here is zed right. So from zed I will get two point two things that is identity let call is that I uh uh if it takashi or t or g and another thing I get is distance let's call it d from zed right wow I'm using the power of C++ auto keyword otherwise I need to write z dot first Z second auto manages all the things right you got to be a coder to love I can't expect coding from newbie now you can nor me oh [ __ ] I read the it's changed the meaning of entertain the meaning of entire chat So it I can't be expecting from norm this is one of the code the work that's makes sense started making sense.
Okay. So instead of this what will takashi or guard?
So zero means it's takashi. Okay. And if it is and one more thing I have to check here if it is takashi or guard that doesn't matter. Uh if it is distance is more than so if d is greater than distance of x comma y then why y why y why y why y why y why y why y why y why y why y why y why y why y why y why y why y why y why y why y why y why y this is this y why y why why this comparison is not okay why this comparison is not working here d right d is the integer inside zed the second coordinate represent present the distance and the first coordinate represent the identity. So this matches the op operant. Why? It's a comparison between integer to integer, right?
Then we have to continue.
I'm still not Wait, wait, wait. I think I have to What's the data type of D? It's a long long What's the data type of this? It's a vector.
Oh, wait. Uh, sorry, sorry, sorry. It's a vector of vector, right? Yeah. Then we have to continue.
Then here dra right then here we have to store the minimum actually we have to break and we got our answer right. So see out what we can do is here see out the d + one.
No, no. We see out the D. Yeah.
And return.
Yes. Yes. Yes. Yes. Yeah. This is fine.
What's going Oh, what's going on my chat?
Seem like a pretty good conversation.
Should I? Let me let me read. It's feel interesting to me.
Okay.
Hey, how to pronounce this person name now?
Zippy creates zippy creates, right?
This is I'm pronouncing correct right. I don't I I call it zippy creates.
That's a chatbot actually working on it on on it has a big project. Hope you won't mind me running it here for some time.
Are you crazy?
You're using a stream as a testing tool.
I don't mind if it is within a slim boundary.
Oh yeah.
So, looks like the boss finally grabs us with this presents. Hope you brought snacks. I brought my snacks and pray that too.
I'm talking to a board for this long.
Nice chat. It's really nice like real time. It's salute, bro. Salute.
Are you serious? Right. This is a chat bot. It's convers. It's doing conversion conversation in a real time.
It's it's not difficult to build but to broad this idea is actually creative by the way. But what if like Yeah. We can manage. Yeah. Yeah. Yeah.
It's actually connecting the dots to me also. This is a good project by the way.
You can you can do whatever you want but it should be within a limit, right?
It's your college project.
in which college I don't know if YouTube doesn't mind then why should I mind but uh it should not divert the chat it should not duck I don't care [ __ ] let me go coding okay so what we'll do if the car Okay.
Now, now there's no difference, right?
We just need a check for this.
Oh, what if Takashi caught? Yeah. Yeah.
We need a check. Takashi caught. If Takashi can't escape, he is caught before reaching the exit or Okay. If it is takasi caught okay or it doesn't reach then we have to print minus one. Yeah that's fine.
College must be nice to escape this is my college doesn't uh accept any creativity.
Yeah realtime project it's good.
So what we'll do here is I have performed the first check that is this does the cashi reach or not. If it is reach if fail to reach in this case the remaining step of is done is not executed no this is actually a nice problem now we have to maintain we have to force actually takashi if guard if any of the guard catches the takashi that means takashi is forced move to coordinate right. Okay.
Then we have to maintain two distance vector. One is the takashes interval and Yeah. Yeah. Yeah. Here we also have to maintain two different.
So this is not going to just simple now. Yeah. I got the complexity of this question. See because we have two identity right in a pre the concept I have discussed that doesn't actually have identity in it itself. Yeah I got it why the constraint is just eight here.
So now because we have two identity and one is the guard identity is takas identity. Both mindsets are different here. Guard mindset is to catch the cashi. The kashi's mindset is is to escape the what is the maze right the real baby labyrinth labyrinth. Yeah. So we need to maintain two distance vector. One distance vector is the takage distance.
Another based on the identity right or we can use one just need to introduce the identity here. This is not going to take you like we are far away from the solution required solution.
Damn bro, what your chatbot is really doing here? This train is so chill. Make me want to code something epic. Anyone else? My third year project was like Zapto but it does data collection with AI. So it can be predict what might customer need in future. So it keep on analyzing the profile and match. It's like a recommendation right.
It's a recommendation system you are building right based on the order. Yeah, it's a recommendation system and it's you have to train your model has sufficient with the sufficient data of the customer with based on the behavior.
It's a here and there modification of ML project. Let me try the third question right because we are far away from the required solution.
I have to save this con.
This is the concept I have to learn like how to maintain two different mindset in a multisource.
We try the third one.
Why we have long stories in all the questions?
This is the see this is the actual reason why I do practice on add coder because add coder doesn't have the long stories like code forces but it started adding the stories here also.
Okay. So, oh on so it's it's like your chatbot is activated based on your username, right?
Because I saw here once you chat your chatbot is responding.
It's fine.
Yeah. Let's see if it is respond or not based on the comment. I don't think so.
Right.
Oh, it is responding.
You forgot what admin had at home.
This doesn't make sense, right?
Not mode adaptive that and what respons did you forget your admin and that I didn't get the conversation. It's fine.
Yeah. Works using the commands and mentions. Okay.
You can make it more versatile, right?
uh you can scrape the data based on the username and then feed the data to your model then your model will give you a precise answer for a particular username and then what should respond in a chat but it need a high infrastructure right okay only admin can use a particular command but I can suggest like you can See for any stream you uh in a background it's a background task just to collect all the users uh chat right and it's ident it's identical because you are feeding your model to a particular data based on the username.
Yeah. Smell o system inter interesting.
Mhm. So each and your it's in a separate thread. You can train your model real time but it need a high infrastructure.
You need a cloud service to do this.
Uh local host also work here but not at high scale but what you can do is try to build something. Yeah. Then your project will be very very impactful if it is a real time.
Hoping V don't start a cult with this.
Just chilling here. Hoping V don't start a cult with this stream.
Now I can see the sarcasm.
It hurts, bro.
Sometime it's fine. Let me inversion of a magic square. Inversion of the magic square.
What that means? Like Oh, [ __ ] I won't know. I won't read big statement now.
Yeah, this is what the small statement means.
The cash is in charge of creating the stand standing for the contest programming contest. Okay, there are end participant in the contest and each participant is assigned number from 1 to end. The rating of participant is AI in the contest. Each participant earn a score. The score on by the participant is BI. Due to the nature of the contest scoring system, the earned score is always is always at least as large as is owning on a chaoke. That's fine. The standing are created according to the following rule. When comparing two participants, the following criteras applied in order of priority to determine who ranked higher. Okay.
Is that the smaller rank number? Okay.
The participant whose highest on rank higher. Okay. If on score are the same, the participant highest rating rank higher. Okay. If both part on the score, no. If both the if both the un score and the rating are same, the participant with a smaller participation rank. Okay.
Since all participation numbers are distinct, the above rule generally determine the rank. That's true. on behalf of Takashi write a program that output just say this is a simulation question right you just need to go that implementation there's no logic we have to apply here yeah this is just a simulation trying with saying like it's a small o system pretty nuts okay so it's always puts a question the chatboard always puts a Right.
I think that's extra, don't you think?
Yeah. Let me try this. be inti and bi vector of pair we just need to apply the compar uh custom sort and it solve our question that's int comma int And let me create a tier.
Okay.
And let me say info.
So first priority is CC. We just need question is too simple. We just need to store the info and that's it. So what is our first priority? The participant highest score. Score is our first priority. Right? So it is BI. Then if the first thing the first indicator is the type then the tiebreaker is the second indicator that is if the earned score are same the participation with the highest rating then AI is the tiebreaker. If BI is also same if AI is also same then the participation uh participation number is the tiebreaker and participation number is always a unique then you will always have a unique rank. Yeah, this is what s = 0 i is less than n i ++ int a int b same a and b. So what I will do here is uh info dot push back makeup.
So B is the first priority, second is the A priority and I is the third priority. And we just need to sort info.
Yeah. And whatever is the final standing that's uh let me iterate auto for auto person.
Uh let's say this is B, this is A and this is I.
from info and simply see out the i + one because it's a one base and right and see out and yeah we don't need this I think this is what the question mean what the why debug info it won't work Here it is working actually. 200 100 200 150.
Yes. Oh. Oh. Oh. No no no no no. We have to use the custom sort here that is int B because see this should come first. Three should come first, then second, then this.
Oh no, no, no. We have to wait. How to write a custom sort? We have a tpple.
We have to the syntax. What is the syntax? This is the syntax, right? We have tpple.
Tupppel of int.
We have tpple. Then we have another tpple.
int, int, int. Let's say B.
Yeah, this is the syntax. What's going on, chat? Let me see.
Do you do it?
Oh, this is out of the context. What I'm doing, bro, your chat. What is bombarding my entire chat?
You had enough testing, right? Let's just stop because let's just stop for now.
So, you get did you get my point right? If if anyone is following what I'm coding here, did you get my point or not?
So the first priority is let me write the return statement here. The first priority is auto X Y uh let me write A1 B1 I1.
Okay.
Is from A. Let me write auto A uh sorry it's a B1 A1 and here I will write uh B2 A2 I2. So what is our we have to return B1 is greater than B2 and end.
A1 is greater than A2.
No no no no or we have to always return B1 if B1 and B2 are not equal.
If B1 is not equal to B2 then we return this.
If they are equal then we have to return what's the second if both are then the part highest rating. Okay. If A1 is not equal to A2 then we have to return a A1 is greater than A2. Else what is the third uh part? Smaller rank. Okay. And then we have to rank return I1 is less than I2.
Now I hope we'll get what we want. Yeah.
3 2 1 3 2 1. Okay.
So this is what we want here and pass. Let me submit.
Let me submit.
Why?
Tell me I got the sorting part. Yeah, that is what no bro you had an interesting idea. You can keep working on that will improve the thing that I told you. If if your chat is if your model is getting feed up with the real time data and come up with an yeah for you there's a clap there's no clap here right the celebration so reach the sorting part did you get is right that is what we have to do based on the priority we have sorted and that and what's the output let me summit After this question, we'll move to the lead code.
Any specific question you want me to try?
Uh 72 test cases, 34.
We got AC. Yes.
Any record any specific question any record question do daily code question I used to do daily code question but then I stopped doing late code question because I don't know why let me show you my graph time I used to do lit code question this is the time.
This is the time I used to do it question daily.
Uh the one more thing I got the last contest is a pretty good contest. That's the last last week, right? I got 40 plus.
Hopefully I will cross 800 and it will my first time if I cross it.
My highest my highest rating is 7 1799.
This is my second highest rating 1798.
I'm hoping I will cross 800. If I'm if I perform pretty well or if I [ __ ] it up then again I will lose all the AC means accepted. accepted.
No, no. AC means accepted. Add coder means add coder. There's no shortcut for Can you suggest my channel?
Any channel in its website too?
Uh Mr. Beast Mr. Beast has its YouTube channel website, right?
Then this uh there what the TV uh no not TV MTV music or what there's one that also has a YouTube channel and website not channel website means for what purpose you go to contest from which contest you want mean change This channel is not channel. I didn't get your point.
Oh, sorry, sorry, sorry, sorry. [ __ ] [ __ ] [ __ ] Yeah, yeah.
Where's your website? I haven't saw your website yet. You know, chat board that what I can suggest.
It always ask you in a form of it always reply in a form of questions, right? So make it generic because it's a predictable. If your response is always a question, then anyone can predict, right? It's a chatbot or it's some kind of AI.
That's true.
That's true.
I almost spend an hour and then realize, yeah, I'm far away from the solution.
That's the biggest [ __ ] Any particular question we can try from bi-weekly first let me check how much AI is able to solve.
Okay, this question is pretty good. Then AI is unable to solve the third question. Can we solve the third question?
No.
Constraint is see the constraint we definitely need hardcore DP here what we can what I'm thinking is let me freshen up and and focused I will do a live stream a focused live stream where I will not interact with chatter much while solving a problem and I will Try elite code virtual contest.
I did the first and I will try the third then third looks interesting to me by seeing the problem. I will like what I'm thinking is we need to find the intersection like minimum or maximum. H this isn't let's not spoil the question.
Today night or tomorrow? Let me think.
Today night we don't have any contest right? I check my calendar.
This is my alternative account. Don't judge on me.
We don't have contest today. Yeah. So what we'll do is today night I will do a live stream of bi-weekly virtual bi-weekly of Mhm. That's good. with a fresh mind.
Change your chat to This is live chat, right?
This is live chat, bro.
Change your chat to live chat instead of top chat. How to do that?
This is live chat, right?
Oh, okay. Okay.
Yeah, I changed from top chat to live chat.
No, no, no. I'm ending my chat now. You can chat URL from where I get the URL.
from where I will get the URL.
That's fine. So, let's end the stream here and we'll do the focus live stream tonight and attempt live virtual by weekly.
Okay.
Thanks everyone for joining.
Yeah, you are a bro. That's true.
So, thanks everyone for joining. We'll meet tomorrow. Yeah, in night somewhere around somewhere around after dinner.
I'm not fixed with the time. We'll we'll do some live stream at night. That's for sure.
Okay, guys. Bye-bye.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 views•2026-06-01











