# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Name |
---|
And what?
I think the best way of getting some idea about a problem's solution is looking at the editorial. Here's the Round 533 (Div. 2) editorial: https://mirror.codeforces.com/blog/entry/64664
It's a simulation problem so your task is only to simulate the game following a given set of rules. They're unequivocal so for a particular initial grid, there's only one correct course of the game. The algorithm that you need is multi-source BFS. Firstly, put on the queue all of the cells which belong to some player. Then, simulate the turn as below: Take one player (which is first in order) and using BFS, expand his cells. Then, take the next player... finish it when there are no empty cells left.
If you put on all cells, which belong to some player, in the queue, I'm not sure that it is a clear O(n^2), because every move you traverse over all visited cells. And if the moves are a lot (a sample can be constructed) the complexity can possibly reach O(n^3). One possible optimization is to put only cells, which were end points on the previous move. It's pretty obvious that the other cells are useless and you can observe that this way we visit every cell at most twice, which leads to a clear O(n^2) solution. The most solutions passed without this, but in my opinion the test cases are pretty weak.
Of course, that's what I meant. We put all cells which belong to some player only in the first move. Then, only these which are 'new'. Like in normal BFS. Thanks for clarification because I didn't say it plainly. Really, did solutions O(n^3) passed? So the test cases were really weak.