-
-
Save enzerr/cffce57511d821786bdeab9e7c0f0b46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
const int maxn = 2e5 + 5; | |
int bit[2][maxn], freqx[maxn], freqy[maxn]; | |
void upd(int id, int tp){ | |
for(; id < maxn; id+=id&-id) bit[tp][id]++; | |
} | |
void nupd(int id, int tp){ | |
for(; id < maxn; id+=id&-id) bit[tp][id]--; | |
} | |
int sum(int id, int tp){ | |
int rt = 0; | |
for(; id>0; id-=id&-id) rt += bit[tp][id]; | |
return rt; | |
} | |
int main(){ | |
int n, m; cin >> n >> m; | |
int q; cin >> q; | |
while(q--){ | |
char tp; cin >> tp; | |
int x, y; cin >> x >> y; | |
if(tp=='A'){ | |
if(!freqx[x]) upd(x, 0); | |
if(!freqy[y]) upd(y, 1); | |
freqx[x]++, freqy[y]++; | |
} | |
else if(tp=='R'){ | |
freqx[x]--, freqy[y]--; | |
if(!freqx[x]) nupd(x, 0); | |
if(!freqy[y]) nupd(y, 1); | |
} | |
else{ | |
int x2, y2; cin >> x2 >> y2; | |
if(x2<x) swap(x, x2); | |
if(y2<y) swap(y, y2); | |
if(sum(y2, 1)-sum(y-1, 1) == y2-y+1 || sum(x2, 0)-sum(x-1, 0) == x2-x+1) cout << "S\n"; | |
else cout << "N\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment