A11295 | Turtle Magic: Royal Turtle Shell Pattern
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The first line of the input contains a single integer $t$ ( $1 \le t \le 10^3$ ) — the number of test cases.
The first line of each test case contains three integers $n$ , $m$ , $q$ ( $5 \le n, m \le 10^9, 0 \le q \le \min(n \times m, 10^5)$ ).
The $i$ -th of the next $q$ lines contains two integers $r_i$ , $c_i$ and a single string $\text{shape}_i$ ( $1 \le r_i \le n, 1 \le c_i \le m$ , $\text{shape}_i=$ "circle" or "square"), representing the operations. It is guaranteed that the cell on the $r_i$ -th row and the $c_i$ -th column is initially empty. That means, each $(r_i,c_i)$ will appear at most once in the updates.
The sum of $q$ over all test cases does not exceed $10^5$ .
The first line of each test case contains three integers $n$ , $m$ , $q$ ( $5 \le n, m \le 10^9, 0 \le q \le \min(n \times m, 10^5)$ ).
The $i$ -th of the next $q$ lines contains two integers $r_i$ , $c_i$ and a single string $\text{shape}_i$ ( $1 \le r_i \le n, 1 \le c_i \le m$ , $\text{shape}_i=$ "circle" or "square"), representing the operations. It is guaranteed that the cell on the $r_i$ -th row and the $c_i$ -th column is initially empty. That means, each $(r_i,c_i)$ will appear at most once in the updates.
The sum of $q$ over all test cases does not exceed $10^5$ .
输入格式
For each test case, output $q+1$ lines. The first line of each test case should contain the answer before any operations. The $i$ -th line ( $2 \le i \le q+1$ ) should contain the answer after the first $i-1$ operations. All answers should be taken modulo $998\,244\,353$ .
输出格式
In the second sample, after placing a circle-shaped fortune cookie to cells $(1,1)$ , $(1,2)$ and $(1,3)$ , the condition is already not satisfied. Therefore, you should output $0$ .
输入输出样例
输入 #1
2 6 7 4 3 3 circle 3 6 square 5 3 circle 5 4 square 5 5 3 1 1 circle 1 2 circle 1 3 circle
输出 #1
8 4 3 1 0 8 4 1 0
In the second sample, after placing a circle-shaped fortune cookie to cells $(1,1)$ , $(1,2)$ and $(1,3)$ , the condition is already not satisfied. Therefore, you should output $0$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted