CF1933G.Turtle Magic: Royal Turtle Shell Pattern

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The first line of the input contains a single integer tt ( 1t1031 \le t \le 10^3 ) — the number of test cases.

The first line of each test case contains three integers nn , mm , qq ( 5n,m109,0qmin(n×m,105)5 \le n, m \le 10^9, 0 \le q \le \min(n \times m, 10^5) ).

The ii -th of the next qq lines contains two integers rir_i , cic_i and a single string shapei\text{shape}_i ( 1rin,1cim1 \le r_i \le n, 1 \le c_i \le m , shapei=\text{shape}_i= "circle" or "square"), representing the operations. It is guaranteed that the cell on the rir_i -th row and the cic_i -th column is initially empty. That means, each (ri,ci)(r_i,c_i) will appear at most once in the updates.

The sum of qq over all test cases does not exceed 10510^5 .

输入格式

For each test case, output q+1q+1 lines. The first line of each test case should contain the answer before any operations. The ii -th line ( 2iq+12 \le i \le q+1 ) should contain the answer after the first i1i-1 operations. All answers should be taken modulo 998244353998\,244\,353 .

输出格式

In the second sample, after placing a circle-shaped fortune cookie to cells (1,1)(1,1) , (1,2)(1,2) and (1,3)(1,3) , the condition is already not satisfied. Therefore, you should output 00 .

输入输出样例

  • 输入#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,1) , (1,2)(1,2) and (1,3)(1,3) , the condition is already not satisfied. Therefore, you should output 00 .

首页