framework of size n×m, with the end goal that every cell of it contains either 0 or 1, is considered lovely if the total in each adjoining submatrix of size 2×2 is actually 2, i. e. each "square" of size 2×2 contains precisely two 1's and precisely two 0's. You are given a network of size n×m. At first every cell of this network is unfilled. How about we indicate the cell on the crossing point
Code in C++ only. Correct answer will upvoted else downvoted.
framework of size n×m, with the end goal that every cell of it contains either 0 or 1, is considered lovely if the total in each adjoining submatrix of size 2×2 is actually 2, i. e. each "square" of size 2×2 contains precisely two 1's and precisely two 0's. You are given a network of size n×m. At first every cell of this network is unfilled. How about we indicate the cell on the crossing point of the x-th line and the y-th segment as (x,y). You need to handle the inquiries of three sorts: x y −1 — clear the cell (x,y), in case there was a number in it; x y 0 — compose the number 0 in the cell (x,y), overwriting the number that was there already (assuming any);
x y 1 — compose the number 1 in the cell (x,y), overwriting the number that was there beforehand (assuming any). After each question, print the number of ways of filling the unfilled cells of the grid so the subsequent network is delightful. Since the appropriate responses can be enormous, print them modulo 998244353.
Input :The principal line contains three integers n, m and k (2≤n,m≤106; 1≤k≤3⋅105) — the number of lines in the framework, the number of sections, and the number of inquiries, individually. Then, at that point, k lines follow, the I-th of them contains three integers xi, yi, ti (1≤xi≤n; 1≤yi≤m; −1≤ti≤1) — the boundaries for the I-th inquiry.
Output :For each question, print one integer — the number of ways of filling the unfilled cells of the grid after the individual inquiry.
Step by step
Solved in 4 steps with 1 images