 All right guys already started this contest, but probably it was super easy. So we start we're gonna do be now You have n products that price of I th product is P I the I th product has C I functions the jth function The jth function and of the I th product is represented f of i j between 1 and m What is if there's a product that's superior strictly superior to the other one? There are i and j such that the I th and j th products Satisfy all the following conditions print. Yes, otherwise, no P is greater than equal to PJ you have Price of a product is P I The price of the I th product is P I The I th product has C I functions The jth function Okay, if I j represents The I th the jth the jth function of the I th product is the f i j. Okay, you want to reference the conditions are okay P is greater than PJ the jth Product have has all function of the I th product P I is greater than PJ or the jth product has one more function that the I th product locks jth function of the I th product is represented as an integer f i j between 1 and m inclusive Okay, the first input is Okay, it's like this I j for three Satisfies all the conditions I j is equal to four feet J th product has all function of the I th one j product has all function of the I th product This is really really difficult P of I is greater than equal to PJ. I Don't know that. Oh, wait One two three four one two three. I don't understand a single thing. What is going on here? Absolutely, don't hold up. I'm gonna get I'm gonna turn this turn my camera off. I need to get a pencil and paper Okay, let me see So we have a thousand 10,000 two one three 15,000 three one two four 30,000 Three one three five 5,000. Yeah, 35,000 two one five 100,000 Six One two three four five six. Okay, so this is just the size of What the rest of the input is so this would be one and three so See I is just the size of this Right, and then P1 P1 to Pn So we need to find We need to find a product of the strictest period If there are I and J such that the I th and J th products out of all the phone print Yes, otherwise for now And we only we want to find a PI and PJ. There's PI is greater than equal PJ. So we need to find a value here Or PI is greater than PJ. So one two three four five. This is all P's. So these are all P's So we need a PI. So the PI is four Three that means one two three four wait, let me see One two three four five. Yeah one two three four So this is the 35,000 But he's referring to that's so this is 35,000 and It is PJ PJ's three so one two three. So this is 30,000. So, you know, you know, P4 is greater than P3 The J th product has all functions of the I th product. So for P of four one five has all the values P of three has all the values of So P3 has all values of P four. Yeah, and then what's the last part? PI is greater than PJ Or the J th product has one or more functions at the I th product locks The J th product has one or more functions at the I th product locks. Okay, so so PI So P of four is greater than P of three Right, so that's the one condition or so in our case $35,000 is greater than $30,000 Right, but we also need to know or the J th product has one or more functions at the I th product locks So we need to check P3 has one or more values that the Okay, I think I understand how to do this. Okay Wow, this is like super different this one's like This is just hard to understand. Okay. All right, we have M and M Fudge kicks. Uh, let's call it F. We need to do this. What is M though? I think there's never use. Oh Between 1 and M inclusive. Okay. Oh Okay, um This is so ridiculous Okay, so we have P See and then I have to loop got a push. Let's just call it each So we're gonna do each dot push Back we're gonna push P And then we're gonna push See And for a C values We're gonna push. Oh Fuck do you actually do even care of of C1? I don't think we care about the C values. That's just a number. There's just a length. We don't actually care about this Oh, I don't have a K here. I do have a K. Okay, C and K push back F dot push back Okay, um Okay, oh So we need to loop through every I th and J th value. So why is this so difficult? Okay? Oh fuck, okay Why is this? Ridiculous Plus one J's less than NJ plus plus We're going through these We're going through this array at the 0th column. So if F at I at the 0th column Is greater than equal to F at J at the 0th column Is it only in this case? Then we also need to check if I is not equal to J um Unless we need to check J th product has all the functions of I th product. I don't think it matters we sort these might not So if all functions if all product I don't know some function. We're gonna use We need to check one more we need to check if F of I at 0 is greater than F of J 0 Said this or the j part is one of our functions Another function here then we're gonna see out. Yes And then we're gonna return Otherwise, we're going to see out now. Okay. Oh, that's when we take the I th in the J we need to take F I J and F and then we need to check if the oh loops from F at 1 Down and make sure all they have all the values of where was it the jth has all the values of I th product Okay, so this is not hard all products. This is just a pain to the right understand right Okay, so we're gonna loop from Okay No, okay Why is it so difficult the jth product has to have all the function of the I product jth product So if I look from this to that Okay, I could sort from one to the end so I could sort No, the I thought it has to have all the value The jth product has all functions of the I product. Oh Yeah So the ah So one three five must have one and five So I could just loop through all of oh I Jth function needs to have all of the I th values Okay, um, oh, okay, my brain's hurting Okay, we could just create a set of all the oh, yeah, so this is all I values So we could just add it D is equal to zero these less than f of I Size D plus plus so we need to add all values dot insert I D I think But we want to start from one So this the jth must have all the values of I so The jth must have oh Wait, we can use a map here store this Right, and then oh, I'm trying to think what we're supposed to do all j values What's what's doing here? It's so annoying Okay, so now we have all the I values and all the j values and then we need to check if the j product has all of the I values so we're gonna go through all the I values and check if J at all the I values f of all J values at all I values is Greater than equal to all I values Yeah, so if I go through all I values I need to check if the all J values at X dot first right is greater than or equal to all J values at All I values X dot first So if it is then continue otherwise Return false and here return true Yeah, I think this would work Although I'm kind of building this every time though One or more functions. Oh That's just exactly the same thing as what we wrote above But we have to build this again. We're kind of building this every again every time That's a problem, but for now. I don't think it matters What the fuck? Okay, the the jth product is one or more function that I product lacks J is probably one of our function Oh So, okay, I think this would work, but I don't know Whether or not it's efficient. I don't know I'm gonna print the index fuck Stop stop. What is it error? I should return C out I J also so this should be You should give me 3 2 actually Because I'm using zero indexing you add one also Come on 3 2 yeah, that's right Should give me no 1 2 what 2 2 3 was it 1 2 so p of 1 Okay, that's right. Um What is the next one p2 has all values? No, this is not it Should not have all values of p1. So something's not right with this one. Oh No, we don't have a value of 1 This should have given you false This should give you false. Well, what is I and J? What did I say my answer was wait, hold up 1 and 2 to 0 That is true p2 has all values of p1. Yeah They're very equal to but the last push check was how it should work. It's where this TLE is. I don't I don't know Yeah, no, um, let's sanity check the first one 3 2. Yeah, that's right. I don't know what this is 0 3. Okay All right. Now. We just don't need to print this out and we just just submit it I don't know why this took me so long to figure it out. It took me so long to understand this Wrong answer One wrong answer What could that be? Oh my gosh? What could that be? Oh? What could this be? You could add all both of them to an array and then sort them both and then check if they're the same They're not the same return false. We could do that also Hell yeah, we got a seed All right, that was as hard as fuck All right. Oh my god of strings All right, we have to try to at least solve three right now So be was hard be was hard to understand. We need to try C and D. Let me see the standings Where's my score 100? Well, what's standing right now? Pretty low right now because I didn't do it fast enough. I also joined in late I Thousand what is that? This guy's cheating and this guy Michi is gonna increase. I Don't know. All right. I don't know what it was a third problem hard There and sticks with silver balls on to them each ball has You should have written on it was reversal I stick is the The number of balls stuck on to the I stick is S of I S of I is a sequence of the letters on the ball starting from one end of the stick Two sticks are considered the same when the sequence letters on the ball starting from one end of the stick is equal to sequence starting from the other end of So for integers I and J The jth stick is considered same if and only if S of I equals to S to J or it's reversal So what what are you trying to find? The light of the string Wait, the number of balls stuck on to the I stick is a length of the string and As I is a sequence of letters on the ball starting from one end of the stick Two sticks are considered the same when the sequence of letters on the ball starting from one end of the stick It equal to sequence like starting from the other stick So integers I and J between One and includes of the ith and J sticks are considered the same if only if S of I is equal to S of J or it's reversal For them the number of different sticks among n sticks. So Okay, so we have okay I might just go straight into the So we have one two three four five six. Okay Um ABC is equal to the reversal of S4 so S2 so one two three four five six S2 is equal to the reversal as four. So this is equal to that So the second and the fourth sticker consider the same S2 equals the S6 ABC So the second and six six are considered the same first second and sixth Third is same as fifth. Oh Yeah, I don't know second and six easy to count Because there's they're just the same, right? Third and fifth are also just the same So I would just be two Second and fourth. So one two and oh, okay, this is so easy. Okay loop through use a map add one Um, count the ones are already like repeating. So if you're if you're already repeating You string LL if you already are repeating so if it's already greater than zero then Increment one to the counter, right? So just keep going down keep inserting it otherwise we're gonna insert it. Okay, so Okay, so this is not that hard And then all we need to do is find the ones that are repeating like Equal to the reversal, right? And that's not hard because all we have to do is just Reverse it and check if the map is greater than one. Yeah, so this is not hard. Uh, The second problem was already really hard. I just call it p or something p dot push. Okay. So so so so, um So this is gonna be occur All right, so we're gonna loop through This Ah, okay, so we have to go back For every string We'll build an occurrence. So if occur At x dot first, right? So if this occurs already greater than zero, we're gonna do a count plus plus Why can't I do this? Count plus plus Otherwise if it's we're going to do occur at x plus plus Right. So if it's already greater than zero, so so if we reach to something that Greater than zero, then we're gonna add one to it um Yeah, and then that would just be the number of different ones Now all we have to do is loop through it again and then reverse it and should do the exact same thing So we just have to do loop through it again So we loop through this one This time we're going to reverse it So I'm going to do oh Oh my gosh Uh cba And then if there's a cba, it's greater than it Yeah, so this time we're going to reverse it So I think I could do that. Uh string Reverse rev count plus plus rev plus plus This time Um, we need to create an occur of why is this so hard? Uh rev occur Okay, now we just see our count Okay, so I think this should still work also Though I'm not 100 percent sure There should be three Now if it gets greater than three because we over counted we could just divide by two see that does anything. Oh, fuck. It's four Goddamn it. Okay. Uh, why is it four? Why are you four? Okay, so we add a We add abc We add de We add cba Okay, we see a de again So we add plus one We see a abc again, so we plus one So we have two And that's it rev counter. Okay, so a we reverse a We get a Doesn't exaggerate. Nope. So we add a to it. Okay um abc reverse abc cba Nope Answer cba So we have a cba Um de we're gonna reverse it. We get ed so add ed um Oh It's counting. Oh, oh my god. This is so ridiculous. Okay. Um We don't want to store reverse we want to abc ed Oh So we want to go back to this occurrence right here and we rather just reverse it and then check if this Is also Greater than zero So we need to oh we could do an or occur at rev Is also greater than zero So that's the case. This should give me three Yeah, I should give me three So now here's the problem is I don't there might be a case where this fails I just don't know if this is true or not two wrong answers How many wrong answers do we have We only have one a c everything else is wrong Oh The number of balls stuck under the ij is the length of it Oh Oh Okay, I think I understand We don't want to do this while it's doing it We want to use the same occurrence. So we want to loop through the string again Do this but then this time we reverse it and we don't use this so we don't increment the count We only do this so we do string x Uh God damn it. I just completely deleted v is equal to x Reverse v dot begin. This is so painful Why is it six just divided by two in the end? Reverse What What okay reverse cannot equal to itself Okay, so we got three Why wait wait wait wait wait wait no no no no no a a bc Oh, we already seen a bc Okay, create a set This you already see Ah seeing a scene There's like a fucking bull shit No So hard What's the four? We've already seen a bc Why is it four? Why is it four though? So reverse four, okay I've seen a Why is this four? Okay. So so this one's right a bc. We already seen a bc insert a bc Oh my god Okay, um So this is three. I don't I think I'm gonna get another wrong answer though What is the wrong answer? Please tell me I got like at least one more right Okay, I got so everything else wrong Uh We add both the reversal and the thing to the string So we add both Uh-huh Three It should be three. So yeah, this is right. Oh, let's see if this works I'm gonna throw a poop at the wall at this point Someone poop at the wall All right, if we're still getting another wrong answer, then maybe we should actually look up some test cases This is just throwing poop at the wall I'm throwing poop at the wall Still wrong. Okay. Oh, okay What is the standing right now because I think I'm losing points But you don't gain points until you actually solve the problem. So it doesn't really I feel like more people solve the second problem now. Okay. Yeah Those are still be great We could solve this third one. I believe What is okay? Can I just use I could What are the input statements? That's pretty big. Um, all right, since we already have both of the stuff here, uh We could brute force I need the brute force to work And then we could think about It's gonna be six Oh Okay, I don't know if I could do this. I don't know if we could do this. Uh I think you can though, but I don't know No, uh You'll see bullshit Okay, string x is going to equal to p at i We're going to do p at i is going to equal to Okay, um Why are you not working? It's literally changing all the values here. Um Yeah, if um Do it here Why's it four now? What Oh We still need this, but we're going to mark all the values. So we're not going to do this What we are going to do is we're going to create a set string marked Okay, that that okay. I I okay, so this is right, but I don't even know if Okay, so hold up Let me just make sure the marked is right. I'm gonna just throw in poop on the wall. Oh stop What is marked? Hopefully this works Come on unless I'm double counting again Oh my god, what am I double counting? We need to find a brute force solution or it's reversal. Yeah, okay Here's what am I thinking If you add seven and then a cba again, it should still be three So if we do So if we put seven And then we do All this stuff and then we add another cba. It should still be three Yeah, okay, so that's That was that test case Wait, no It should be four Hold up man, I should Can I debug this in time? Which time should be four though? Okay, I think I've got another idea So we're not going to use marked. Oh wait, we are going to use marked But instead we're going to reverse marked So we're gonna do insert reverse Then if any of these values, no, then if I go through p And if x is equal to Fuck we have four minutes left. Oh go through our reverse. Oh fuck. I don't think that would I don't think that makes any sense Oh Wait, fuck it. Let's just submit this. Am I doing wrong? What is what am I doing wrong? I I don't get it. All right. I'm curious. How do you do this problem? Oh my gosh, how do you do this problem? How did this guy get the first second problem wrong? Huh, I don't understand. How do you do see? I don't understand uh to Oh Oh my gosh All right, I don't know. Hope you guys enjoyed this video. Very calm subscribe. I'll check you guys later. Peace