How can I solve Problem 275A ? http://codeforces.net/problemset/problem/275/A
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3839 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3612 |
7 | Geothermal | 3569 |
8 | ecnerwala | 3494 |
9 | Um_nik | 3396 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | Um_nik | 164 |
2 | -is-this-fft- | 161 |
3 | maomao90 | 159 |
3 | atcoder_official | 159 |
5 | cry | 158 |
5 | awoo | 158 |
7 | adamant | 155 |
8 | nor | 154 |
9 | TheScrasse | 153 |
10 | Dominater069 | 152 |
How can I solve Problem 275A ? http://codeforces.net/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.net/contest/275/submission/20742578
I hope I helped you.
Here is my Solution : https://codeforces.net/contest/275/submission/126631294
nice ping bro