P9198题解
Nuyoah_awa · · 题解
题目大意
给定一个
题目分析
我们可以按照题目要求每次更改一个数,再看是否对称。
时间复杂度
我们发现,每回只改一个值,所以我们可以记一个
- 原来这个点对称,后来这个点依旧对称(改了跟没改一样):
cnt 不变。 - 原来这个点对称,后来这个点不对称(改不对称了):
cnt + 1 。 - 原来这个点不对称,后来这个点依不旧对称(好像改了,但是没完全改):
cnt 不变。 - 原来这个点不对称,后来这个点对称(改对称了):
cnt-1 。
每次改完后,如果 Yes。
否则说明有点不对称,输出 No。
code
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 105, MOD = 256;
struct node{
int a[4];
}p[N][N];
int n, m, q, x, y, t, c, cnt;
bool operator == (node u, node v)
{
for(int i = 1;i <= 3;i++)
if(u.a[i] != v.a[i])
return false;
return true;
}
int main()
{
scanf("%d %d %d", &n, &m, &q);
for(int i = 1;i <= q;i++)
{
scanf("%d %d %d %d", &x, &y, &t, &c);
if(p[x][y].a[t] == p[x][m - y + 1].a[t])
{
(p[x][y].a[t] += c) %= MOD;
cnt += (p[x][y].a[t] == p[x][m - y + 1].a[t]) ? 0 : 1;
}
else
{
(p[x][y].a[t] += c) %= MOD;
cnt += (p[x][y].a[t] == p[x][m - y + 1].a[t]) ? -1 : 0;
}
(cnt == 0) ? printf("Yes\n") : printf("No\n");
}
return 0;
}