By a7mads3ed, history, 5 years ago,

How can I solve Problem 275A ? http://codeforces.com/problemset/problem/275/A

• -1

 » 5 years ago, # | ← Rev. 8 →   0 Consider a simpler problem:Every time you press a light only the light pressed will be toggled.Now it is obvious that if a light is pressed event number of times it will be in it's initial state (ON).Now to solve the initial problem:Let pressed[3][3] be the initial matrix and toggled[3][3] the matrix of total lamp presses.In the beginning pressed[][] = toggled[][].Now if pressed[i][j] != 0 then we have to add pressed[i][j] to toggled[i][j + 1], toggled[i][j - 1], toggled[i - 1][j] and toggled[i + 1][j]. Now we are left with the first, much simpler problem.But be careful when handling edge lamps.My solution (see how I handle edge lamps): http://codeforces.com/contest/275/submission/20742578I hope I helped you.
•  » » 5 years ago, # ^ |   0 Here is the same idea, but with different implementation. well, just consider it as another reference, haha :)275AHope this helps :)
•  » » 15 months ago, # ^ |   0 Thanks a lot, Buddy!
•  » » 6 months ago, # ^ |   0 why the array is declared as global ?is there any reason?
 » 2 months ago, # |   -18 Here is my Solution : https://codeforces.com/contest/275/submission/126631294
•  » » 2 months ago, # ^ |   0 nice ping bro
•  » » 2 months ago, # ^ |   0 why everyone down-voted for my submission? is my approach is wrong?
•  » » » 5 weeks ago, # ^ |   0 You complicated the solution unnecessarily, that is why
•  » » » » 5 weeks ago, # ^ |   0 And you necroed, that is why