Codeforces Round 683 (Div. 1, by Meet IT)
E
Long Recovery
Codeforces
3500
原题
← D2F →
翻译中…

A patient has been infected with an unknown disease. His body can be seen as an infinite grid of triangular cells which looks as follows:

翻译中…

image

翻译中…

Two cells are neighboring if they share a side. Therefore, each cell ($x$, $y$) has exactly three neighbors:

翻译中…
  • ($x+1$, $y$)
  • ($x-1$, $y$)
  • ($x+1$, $y-1$) if $x$ is even and ($x-1$, $y+1$) otherwise.
翻译中…

Initially some cells are infected, all the others are healthy. The process of recovery begins. Each second, for exactly one cell (even though there might be multiple cells that could change its state) one of the following happens:

翻译中…
  • A healthy cell with at least $2$ infected neighbors also becomes infected.
  • An infected cell with at least $2$ healthy neighbors also becomes healthy.
翻译中…

If no such cell exists, the process of recovery stops. Patient is considered recovered if the process of recovery has stopped and all the cells are healthy.

翻译中…

We're interested in a worst-case scenario: is it possible that the patient never recovers, or if it's not possible, what is the maximum possible duration of the recovery process?

翻译中…

Input

翻译中…

The first line contains one integer $n$ $(1 \leq n \leq 250000)$  — the number of infected cells.

翻译中…

The $i$-th of the next $n$ lines contains two space-separated integers $x_i$ and $y_i$ $(0 \leq x_i, y_i \lt 500)$, meaning that cell $(x_i, y_i)$ is infected. All cells $(x_i, y_i)$ are distinct, and all other cells are considered healthy.

翻译中…

Output

翻译中…

If it is possible that the organism never fully recovers from the disease, print SICK. Otherwise, you should print RECOVERED and in the next line an integer $k$  — the longest possible recovery period, modulo $998244353$.

翻译中…

Note

翻译中…

For the first testcase, the following drawings describe the longest possible recovery process. It can be proven that there are no recovery periods of length $5$ or longer, and the organism always recovers in this testcase.

翻译中…

image $\hspace{40pt} \downarrow$ image $\hspace{40pt} \downarrow$ image $\hspace{40pt} \downarrow$ image $\hspace{40pt} \downarrow$

翻译中…

$\hspace{15pt}$ RECOVERED

翻译中…

For the second testcase, it is possible for the cells $(2, 0)$, $(2, 1)$, $(0, 1)$ to become infected. After that, no cell can change its state, so the answer is SICK, as not all of the cells are healthy.

翻译中…

样例

Input #1
4
0 0
1 0
2 0
0 1
Output #1
RECOVERED
4
InputCopy OutputCopy
Input #2
3
1 0
3 0
1 1
Output #2
SICK
InputCopy OutputCopy
题目信息
题号
1446E
时间限制
3 s
内存限制
256 MB
标签
构造
DFS 及类似

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。