#P8562. CSP-J 2202: The AK Challenge
CSP-J 2202: The AK Challenge
CSP-J 2202: The AK Challenge
After a brief disorientation, you realize that you are sitting in a computer room in the year 2202 – specifically, in the contest hall of CSP-J 2202.
Before you lies a challenge that consists of four different problems. A mysterious voice whispers: "Want to know what’s going on? Then demonstrate your past abilities and beat this CSP-J as easily as before!"
The four tasks are as follows:
- Given a positive integer \(n\), compute \(\lfloor \sqrt{n} \rfloor\).
- You are given a bipartite graph with \(n\) vertices on each side and \(m\) edges. Compute the number of perfect matchings modulo \(998244353\).
- Conway's Game of Life is played on an infinite two-dimensional grid. Each cell is either empty or occupied by a cell. At every iteration, the following rules are applied (see the image for details):
Given an initial configuration, determine the number of live cells after \(k\) iterations.
- Given an undirected graph with \(n\) vertices and \(m\) edges, each vertex can be colored with one of \(k\) colors. Adjacent vertices (i.e. vertices connected by an edge) must not share the same color. Compute the number of valid colorings modulo \(998244353\).
Important: The input data is provided in an attachment below the problem statement. You must use this input data as supplied.
Note: The first integer in the input will indicate which task you are to solve. Use the corresponding input format described below.
inputFormat
The first integer T
(1 ≤ T ≤ 4) specifies which task to solve. The rest of the input depends on the value of T
as follows:
- Case 1 (T = 1):
- A single integer
n
(1 ≤ n).
- A single integer
- Case 2 (T = 2):
- Two integers
n
andm
, where there are n vertices on the left and right of the bipartite graph, and m edges. - Then follow
m
lines, each containing two integersu
andv
(1-indexed). An edge connects the u-th vertex on the left side to the v-th vertex on the right side.
- Two integers
- Case 3 (T = 3):
- Two integers
k
andc
:k
is the number of iterations in Conway's Game of Life, andc
denotes the number of live cells initially. - Then follow
c
lines, each with two integersx
andy
representing the coordinates of an initially live cell.
- Two integers
- Case 4 (T = 4):
- Three integers:
n
(number of vertices),m
(number of edges), andk
(number of colors). - Then follow
m
lines, each containing two integersu
andv
representing an undirected edge between verticesu
andv
.
- Three integers:
outputFormat
Output a single integer – the answer for the chosen task. For tasks 2 and 4, output the answer modulo \(998244353\).
sample
1
10
3
</p>