 All right guys, this is gonna be my attempt at SRM Whatever this is a 12. Okay. Have not done CP in a long time So I'm just gonna try to code bash the first thing code bash Code whatever the hell they call it. What do they call it? Just like type as fast as you can Those on it. Yeah, it started a spider attack What does the cost mean? some number of actions you have to spend on using the card for Why is it six? You can only play one of these two cards Meaning Carter cars two cards to play Where is that mean? Reach violet index out. You have a card of actions that deals damage And some number of actions you have to spend on using the card You can only play each card once Number of actions you have to spend on using the card Why what does that affect you? So I have two two one or some okay Wait, you only can spend up to three actions on playing your card Okay, so we have three three minus three Okay Okay They're good. Okay, so I'm gonna pair up all the values. I'm gonna sort it by the increasing order of the cost and Then I'm gonna subtract the total cost of three from each of the values While adding it up and then whichever and then I'm gonna loop you from the beginning also Hope that makes sense So I'll just I'll just do it right now. I don't have time for this Now I'm gonna sort it and I'm gonna do Okay, it's the first total. I'm gonna try the second total starting from the beginning plus equal to Second minus equal values at I dot first And then What a mess I talk I post post. Yeah, and here we return Not cost Okay, so we have two two five six Cost of two. Oh, no. Why does it do 11? Oh Because I can't do because I have one I can't do subtract by two. I'll do this All right. I just have one Two two one five six one. I don't want to stop. I Don't want to stop this Okay I'll cross greater than zero If cost is greater than equal to this Then we do this Otherwise we subtract So this has to be while cost is greater than equal to greater than zero and if Cost is greater than equal to fouls that first and we could do this Otherwise we just do I plus plus. Okay, this should work. It's just a greedy algorithm. Okay Okay, I'm gonna submit this. Okay. Where's the next problem? Where's the problem set? Let me check the leaderboard real quick Okay, so I got first one. I got like 250 points. We try the second one problem statement Okay, same thing Mars habits design Returning a vector. Okay Okay, I don't need this anymore Okay, okay if size is equal to one. Let's see. Let's look at the size Okay, if the senses is equal to one. It's just return empty. It's a easy one. Um Zero ten in the example true hub is kind of by three seven quarters one is like ten Draw this out. Why is the array one ten one forty two one forty seven zero ten zero forty two zero seven. Oh Is each of them? Oh Okay, so we write on the number and then the length. Okay, but what about the array? What is that? Each half time must have three outgoing quarters Okay, shortest distance from zero to habitat I Okay, so Choice distance from zero to habitat zero is zero wait There's I between Okay, this is zero will be zero. Okay One is ten so from zero to one Okay, okay Excuse me. You're 10 zero 10. Can you just have like two quarters that go to it? Like 47 and then here you have 010 and then you're 10 Okay We're trying to build a directed graph. What are we trying to return though? Holy skates zero to okay one two This is hard 47 42 25 10 22 So we have 47 we do 25 10 22 I'm on the 600 042 42 25 10 22. Okay Zero to one. Okay, you know what screw this. Okay Zero to one is 47 zero to two is 42 zero to three is 25 Zero to four is ten and zero to five is 22 Okay, they can't have for the rest of them. Can I just put them all at Does it have to be does have to be the smallest or no because if it's not I could just literally put whatever Well, you know what's stopping me from just putting okay, you know what I'll just code it Like what's stopping me from just putting Like zero to one is 47. I'll just put 47 there like 147 and then for the four The rest of them just about 146 146 like what's stopping we're just repeating the same value like oh Large distance from zero to zero Zero to zero No, it would be 57. Oh, they're bi-directional, right? That's weird. Okay, so they go both ways When it take 42 though 47 times two There's there's another self loop don't understand Must have exactly three outgoing corridors, but this one has more That each quarter must have a non-negative integer length. Okay, zero zero zero one zero So we connect zero to ten Zero to zero ten zero to one is 42 Zero to one is ten Okay, that's weird Now we have four though Habitat zero will be the communication Center each habitat must exactly have three outgoing corridors. Sometimes both ends up will make a neck to the same habitat This is hard. Did anyone submit this? I know who would submit it is I feel like if I just repeat the same array and then just Like what's stopping me from just repeating the same array? Like if I just Like if I just repeat like 40 zero to one like I just do one Like if I just start from one I just do like push back this and then push the distance Right. Yeah So now we okay, so then here we got a 41 and 47 Now we just have to put like random numbers for the rest Like One to 47 Like okay, like okay, if you just build it. Okay, you know what fuck this We could build like we have answer, but we also want to build G Initialize Completely forgot how to do this I want to do the one line vector thing No, I don't want to do that. Um G at I dot push back Yeah, okay, so we look through from one to distances Then we do we push back G at I Okay, now we're gonna look through G for every row and G if row dot size is less than Three oh my god, this is so difficult. Oh my gosh, okay If the row size is less than three we're gonna push back Okay, so I just okay. So in this case This is really hard. Okay. Um, if we push Okay, if we push okay, so let's say I have like a Holy-ho you call it It's an I don't know what it's called Okay, I should not do it this way. It's not distances. It's She got size Okay, this is gonna be row. I just use these are okay if Yeah, R dot size less than three we have to add more things, but if it's not Every column we just take zero We push back really hard. Okay We loop through the row They want to whatever three whatever is called 234 whatever. I don't give a shit. Okay. We we push back 47 0 to 1 is 47 Okay, and then what do we do now? We're gonna look through the row and then we go through the columns and I go there. So it's going through the columns if The g of r dot size We're gonna go through it. And then what we're gonna do is we're gonna we're gonna add the rows We're gonna add the row Yeah, we're gonna add the row Okay, we're gonna add the row and then we're gonna push back GRC just gonna be the the value And we do that for everything Yeah Then if it's actually it's the less than three We're just gonna add loops to itself. So for this case we just so here Here add a 147 Now we're gonna just add who won 47 again. So for each of the row If it's less than three Okay, while okay, so we have 47 147 It's still less than So what if it was like one forty seven and one two I just want to put self loops on everything besides even to itself Like from zero to what if I just add like 47 to Just repeat it like six times What about you do that? If for each of them just repeat it twice because we don't we know that it's never gonna be Okay, hold up. Yeah, I'm gonna get rid of this 47 to 1 To what the hell do you call it? This is super difficult. This is hard Really difficult really difficult anyone submit. Okay, this this studying father this guy is going to blue I think he's gonna become blue This is really difficult I think it was repeating each of them twice just Teared that twice that twice that twice that twice so for this one Maybe return hands. I don't I think this would be fine But then you need you need to have self-loops. That's the problem. This seems I Don't know if this would work. Why can't I do zero one day one day one day? What's the problem with that? What if I do like We add this and then for two of them we take the distance Push back I again But then we do what's this for? Why would this not work I? Connect zero to one ten and one nine one eight like what's the problem with this? Oh He plus-plus it still not right zero one is still the length of the shortest of the corridors though Do we also just add zero? I mean What difference does it make though? Like two times six is one two three four five six Can it be can it be zero? Come on. Can you get the? smallest Value in your array and have that as your distance is zero Men underscore element How you doing? All right, we're gonna take small s plus plus. What is this? No, oh my god small s plus one still wrong okay One goes to zero goes to one forty seven one goes to ten wait a minute Zero goes to ten Fuck zero goes to one forty seven zero goes to two Forty Ten One is ten okay Zero goes zero forty seven One goes to forty seven zero zero is ten zero zero is ten zero to one Forty seven zero to one is ten wait. Why are these? Something's really not right That doesn't make any sense at all for each habitat I Look at the three quarters that leave it wait at its other end and then the length of the corridor Zero at the other end is ten. I don't understand for each value. I get it. Oh, I get it Wow, I didn't read the problem correctly. I only have ten minutes left. Wow, okay. That's so stupid. Okay these First six one two three four five six are the habitat of zero that's the out That's what's coming out of zero and then the second six is coming out of one That's so stupid. Okay. Okay. I get it Okay, I understand. Okay Okay, I understand. Okay, so What you want to do is you want to put that into a directed graph a graph for all the ones that are not connected We're going to just Loop it to itself So I had it better before my god. This is so stupid. Okay, so we have zero to forty seven I'm gonna connect it one from zero to forty seven and then for the ones other ones here The other two values one one two to two. I'll put like random numbers there for like 50 51 One two three four. I don't have time to code this shit Okay, damn. I think I was to vote. I was doing before was made more sense. I don't think I could code this I could try. Oh, okay. I Need to go back all the way to All the way back to the directed graph. Yeah here, okay So we push back at certain thing here, okay, I got it. Okay, so here exercise plus one I'm gonna fill all the values with negative one Okay, then here G of I Distances at I'm gonna set this to G of zero zero. I It's gonna equal to row zero column Here we're gonna set equal to distances at I yeah row zero okay, so row zeroes are all the fixed values. Okay, and Distances G at distances not at I zero Okay. Yeah, okay We're gonna loop through it our graph and We're not gonna check the size We'll go through row by row if If it's not equal to negative one. Oh if it's equal to negative one continue If it's not equal to negative one, we're going to print out the You should go back call them. So so these would be negative one. This would be negative one Do I have time? I have five minutes left. Okay, this is Chris. Okay, if we have zero zero This is really difficult. This is so hard We have okay, so we have zero going to forty seven. We have one going to forty seven Now whichever outer edges We need to set We need to check. Oh, yeah, if it's less than three then we need to print out, right? I couldn't finish a second problem, but it is what it is What it is Where is my I don't know why they call this data science cuz not really data science. It's more like It's just algorithms hopefully I get Hopefully I get AC on this and not fail system test This should ideally be greedy unless If it's DP then yeah, I definitely fail But I think it might actually just be greedy. I could be wrong It is what it is. I want to create a bot. Oh crap. I just deleted anyway, right come subscribe guys I'll check you guys later Peace