Two cells are adjoining in the event that they share a side. Thusly, every cell (x, y) has precisely three neighbors:    (x+1, y)    (x−1, y)    (x+1, y−1) in case x is even and (x−1, y+1) in any case.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science.

Two cells are adjoining in the event that they share a side. Thusly, every cell (x, y) has precisely three neighbors: 

 

(x+1, y) 

 

(x−1, y) 

 

(x+1, y−1) in case x is even and (x−1, y+1) in any case. 

 

At first a few cells are contaminated, all the others are sound. The course of recuperation starts. Each second, for precisely one cell (despite the fact that there may be different cells that could change its state) one of the accompanying occurs: 

 

A sound cell with something like 2 contaminated neighbors likewise becomes tainted. 

 

A contaminated cell with something like 2 solid neighbors likewise becomes sound. 

 

In the event that no such cell exists, the course of recuperation stops. Patient is considered recuperated if the course of recuperation has halted and every one of the cells are solid. 

 

We're keen on a most dire outcome imaginable: is it conceivable that the patient never recuperates, or on the other hand in case it's impractical, what is the greatest conceivable span of the recuperation interaction? 

 

Input 

 

The main line contains one integer n (1≤n≤250000) — the number of tainted cells. 

 

The I-th of the following n lines contains two space-isolated integers xi and yi (0≤xi,yi<500), implying that cell (xi,yi) is tainted. All cells (xi,yi) are unmistakable, and any remaining cells are considered solid. 

 

Output 

 

In case it is conceivable that the creature never completely recuperates from the infection, print SICK. If not, you should print RECOVERED and in the following line an integer k — the longest conceivable recuperation time frame, modulo 998244353.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole