记录编号 |
572169 |
评测结果 |
AAAAAAAAAA |
题目名称 |
数列操作 C Plus Max |
最终得分 |
100 |
用户昵称 |
lihaoze |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.334 s |
提交时间 |
2022-06-28 16:48:12 |
内存使用 |
5.96 MiB |
显示代码纯文本
#include <iostream>
#include <cstring>
const int N = 1050;
int t, n, m;
int c[N][N];
int lowbit(int x) { return x & -x; }
void add(int x, int y, int v) {
for (int i = x; i <= N; i += lowbit(i))
for (int j = y; j <= N; j += lowbit(j))
c[i][j] += v;
}
int ask(int x, int y) {
int t = 0;
for (int i = x; i; i -= lowbit(i))
for (int j = y; j; j -= lowbit(j))
t += c[i][j];
return t;
}
int main() {
freopen("shuliecplusmax.in", "r", stdin);
freopen("shuliecplusmax.out", "w", stdout);
std::cin >> t;
while (t --) {
memset(c, 0, sizeof c);
std::cin >> n >> m;
while (m --) {
char op;
std::cin >> op;
if (op == 'C') {
int ax, ay, bx, by;
std::cin >> ax >> ay >> bx >> by;
add(ax, ay, 1);
add(bx + 1, ay, -1);
add(ax, by + 1, -1);
add(bx + 1, by + 1, 1);
} else {
int x, y;
std::cin >> x >> y;
std::cout << ask(x, y) % 2 << '\n';
}
}
std::cout << '\n';
}
return 0;
}