0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 14:56:27 +00:00

C - Rooks Defenders

https://codeforces.com/contest/1679/submission/157171848
This commit is contained in:
Baoshuo Ren 2022-05-14 18:26:16 +08:00
parent 4c4504b295
commit 774e0d8a24
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

71
Codeforces/1679/C/C.cpp Normal file
View File

@ -0,0 +1,71 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5;
int n, q, c1[N], c2[N], r[N], c[N];
inline int lowbit(int x) {
return x & -x;
}
void add(int *c, int x, int y) {
for (; x <= n; x += lowbit(x)) c[x] += y;
}
int sum(int *c, int x) {
int ans = 0;
for (; x; x -= lowbit(x)) ans += c[x];
return ans;
}
int main() {
std::ios::sync_with_stdio(false);
cin >> n >> q;
while (q--) {
int t;
cin >> t;
switch (t) {
case 1: {
int x, y;
cin >> x >> y;
if (!r[x]++) add(c1, x, 1);
if (!c[y]++) add(c2, y, 1);
break;
}
case 2: {
int x, y;
cin >> x >> y;
if (!--r[x]) add(c1, x, -1);
if (!--c[y]) add(c2, y, -1);
break;
}
case 3: {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
cout << ((sum(c1, x2) - sum(c1, x1 - 1) == x2 - x1 + 1) || (sum(c2, y2) - sum(c2, y1 - 1) == y2 - y1 + 1) ? "Yes" : "No") << endl;
break;
}
}
}
return 0;
}