 Alright guys, my name is Michael Limb. Welcome to my YouTube channel. Today we're going to go over codeforces round 632a little Artem. Alright, so there's this guy named Artem and he wants to paint a picture. And he wants to paint an N by M board, which is N rows and M columns. And pretty much he wants the number, so he wants to print, paint a picture of black and white cells. He wants B to be the number of black cells that have at least one white neighbor adjacent by the side. And W, the number of white cells that have at least one black neighbor adjacent by the side. So pretty much he wants to have a black neighbor and a white neighbor. Not a black neighbor, a white neighbor. He wants a chess board that has black pieces and white pieces. And he wants to pretty much just paint it good if B is equal to W plus 1. Alright, so I'm going to show you guys how to do this by hand and then I'll explain how to do it. So yeah, B is the number of black cells that have at least one white neighbor. So B is equal to number of black cells that have at least one white neighbor. W is number of white cells that have at least one black neighbor. So we want to create a formation such that B is equal to W plus 1. So what that means is that number of black cells that have at least one white neighbor is going to be one more than the number of white cells that have one black neighbor. So this is actually not a hard problem. When does this case occur? It actually just occurs when you have all blacks besides one and then one white. The reason why is if you look at this, number of black cells have at least one white neighbor. What are the number of black cells that have at least one white neighbor? Well, there's this one that has one white neighbor as adjacent. Remember, we're only thinking about adjacent right next to each other. So the number of black cells that have at least one white neighbor, what is the number of black cells that have at least one white neighbor? Well, there's one, right? There's one here. So B is equal to one because it has one white neighbor over here. Now, what are the number of white cells that have at least one black neighbor? There's one one here. So this is the number of white cells, right? There's one here. So we'll count that as one also. But then we also have to think about the one above and they mean adjacent. Remember, adjacent is not diagonal, right? It's just above and below. So if we look at here, the above, this is B. The number of black cells that have at least one white neighbor, there's two of these actually. So there's one on the side and the one above. So it's actually one plus one, which is equal to two. And as you can see here, B is equal to W plus one. Yeah, that's all there is this problem. You just, all you have to do is just put B's for everything and then leave one white on the bottom corner. And you could do put one white on the top and then leave B's on. It could be either way. You could put a white on the top left and then put B's blacks on everything on the bottom. But yeah, just make sure the white is going to be on a corner. So yeah, that's how you do this problem. I'll just show you the code now. All right, guys. So to do this problem, all you just have to do is just print out all B's except for the last last corner. You just put a W. So what did I do first? I print out all B's for the row and column except for the last row because I need to print a W for that. So this just prints out all B's for everything, not including the last row. So I loop from I equals zero up to number of not including the last row, right? Except for that last row. So N minus one. And then I loop through every single column up to M and then I print a B. So this and then after that, I print out a new line after each column. So this just prints out all B's except for the last row. Then for the last row, I print out all B's except for the last column because I want that last corner to have a W. So I loop from zero up to M minus one, which is everything except for the last column. And then after that, I just print out a W and a new line. So yeah, that's how you do this problem. Yeah, just Raycom subscribe. Oh yeah, by the way, I didn't use any of these. I didn't use flip or I didn't use chart D. You don't really have to. Yeah, that's how you do this problem. Maybe I'll do the second one. I don't know. I have to look out how to do it. But yeah, I'll do this problem in the second one. And then tomorrow I might do a contest as well. So yeah, hope you guys enjoyed this video. I'll check you guys later. Peace.