How can I solve Problem 275A ? http://codeforces.com/problemset/problem/275/A
How can I solve Problem 275A ? http://codeforces.com/problemset/problem/275/A
# | User | Rating |
---|---|---|
1 | tourist | 3690 |
2 | jiangly | 3647 |
3 | Benq | 3581 |
4 | orzdevinwang | 3570 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | Radewoosh | 3509 |
8 | ecnerwala | 3486 |
9 | jqdai0815 | 3474 |
10 | gyh20 | 3447 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 165 |
3 | adamant | 161 |
4 | TheScrasse | 160 |
5 | nor | 158 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 152 |
8 | orz | 146 |
9 | SecondThread | 145 |
9 | pajenegod | 145 |
Name |
---|
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 andtoggled[3][3]
the matrix of total lamp presses.In the beginning
pressed[][] = toggled[][]
.Now if
pressed[i][j] != 0
then we have to addpressed[i][j]
totoggled[i][j + 1]
,toggled[i][j - 1]
,toggled[i - 1][j]
andtoggled[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/20742578
I hope I helped you.
Here is my Solution : https://codeforces.com/contest/275/submission/126631294
nice ping bro