A14503 | Coloring
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A matrix of size $n \times m$ , such that each cell of it contains either $0$ or $1$ , is considered beautiful if the sum in every contiguous submatrix of size $2 \times 2$ is exactly $2$ , i. e. every "square" of size $2 \times 2$ contains exactly two $1$ 's and exactly two $0$ 's.
You are given a matrix of size $n \times m$ . Initially each cell of this matrix is empty. Let's denote the cell on the intersection of the $x$ -th row and the $y$ -th column as $(x, y)$ . You have to process the queries of three types:
- $x$ $y$ $-1$ — clear the cell $(x, y)$ , if there was a number in it;
- $x$ $y$ $0$ — write the number $0$ in the cell $(x, y)$ , overwriting the number that was there previously (if any);
- $x$ $y$ $1$ — write the number $1$ in the cell $(x, y)$ , overwriting the number that was there previously (if any).
After each query, print the number of ways to fill the empty cells of the matrix so that the resulting matrix is beautiful. Since the answers can be large, print them modulo $998244353$ .
You are given a matrix of size $n \times m$ . Initially each cell of this matrix is empty. Let's denote the cell on the intersection of the $x$ -th row and the $y$ -th column as $(x, y)$ . You have to process the queries of three types:
- $x$ $y$ $-1$ — clear the cell $(x, y)$ , if there was a number in it;
- $x$ $y$ $0$ — write the number $0$ in the cell $(x, y)$ , overwriting the number that was there previously (if any);
- $x$ $y$ $1$ — write the number $1$ in the cell $(x, y)$ , overwriting the number that was there previously (if any).
After each query, print the number of ways to fill the empty cells of the matrix so that the resulting matrix is beautiful. Since the answers can be large, print them modulo $998244353$ .
输入格式
The first line contains three integers $n$ , $m$ and $k$ ( $2 \le n, m \le 10^6$ ; $1 \le k \le 3 \cdot 10^5$ ) — the number of rows in the matrix, the number of columns, and the number of queries, respectively.
Then $k$ lines follow, the $i$ -th of them contains three integers $x_i$ , $y_i$ , $t_i$ ( $1 \le x_i \le n$ ; $1 \le y_i \le m$ ; $-1 \le t_i \le 1$ ) — the parameters for the $i$ -th query.
Then $k$ lines follow, the $i$ -th of them contains three integers $x_i$ , $y_i$ , $t_i$ ( $1 \le x_i \le n$ ; $1 \le y_i \le m$ ; $-1 \le t_i \le 1$ ) — the parameters for the $i$ -th query.
输出格式
For each query, print one integer — the number of ways to fill the empty cells of the matrix after the respective query, taken modulo $998244353$ .
输入输出样例
输入 #1
2 2 7 1 1 1 1 2 1 2 1 1 1 1 0 1 2 -1 2 1 -1 1 1 -1
输出 #1
3 1 0 1 2 3 6
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted