How can I solve Problem 275A ? http://mirror.codeforces.com/problemset/problem/275/A
# | User | Rating |
---|---|---|
1 | jiangly | 3976 |
2 | tourist | 3815 |
3 | jqdai0815 | 3682 |
4 | ksun48 | 3614 |
5 | orzdevinwang | 3526 |
6 | ecnerwala | 3514 |
7 | Benq | 3482 |
8 | hos.lyric | 3382 |
9 | gamegame | 3374 |
10 | heuristica | 3357 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | -is-this-fft- | 162 |
3 | Um_nik | 161 |
4 | atcoder_official | 160 |
5 | djm03178 | 157 |
5 | Dominater069 | 157 |
7 | adamant | 154 |
8 | luogu_official | 152 |
8 | awoo | 152 |
10 | TheScrasse | 148 |
How can I solve Problem 275A ? http://mirror.codeforces.com/problemset/problem/275/A
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://mirror.codeforces.com/contest/275/submission/20742578
I hope I helped you.
Here is my Solution : https://mirror.codeforces.com/contest/275/submission/126631294
nice ping bro