How can I solve Problem 275A ? http://codeforces.com/problemset/problem/275/A
№ | Пользователь | Рейтинг |
---|---|---|
1 | jiangly | 3640 |
2 | Benq | 3593 |
3 | tourist | 3572 |
4 | orzdevinwang | 3561 |
5 | cnnfls_csy | 3539 |
6 | ecnerwala | 3534 |
7 | Radewoosh | 3532 |
8 | gyh20 | 3447 |
9 | Rebelz | 3409 |
10 | Geothermal | 3408 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | maomao90 | 173 |
2 | adamant | 164 |
3 | awoo | 161 |
4 | TheScrasse | 160 |
5 | nor | 159 |
6 | maroonrk | 156 |
7 | SecondThread | 152 |
8 | pajenegod | 146 |
9 | BledDest | 144 |
10 | Um_nik | 143 |
How can I solve Problem 275A ? http://codeforces.com/problemset/problem/275/A
Название |
---|
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