Skip to content

Instantly share code, notes, and snippets.

@enzerr
Last active March 22, 2023 20:48
Show Gist options
  • Save enzerr/ba62266fa8b711d42bc89a4f09ea1385 to your computer and use it in GitHub Desktop.
Save enzerr/ba62266fa8b711d42bc89a4f09ea1385 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100 + 5;
int on[maxn][maxn];
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'){
for(int i = 1; i <= n; i++) on[i][y]++;
for(int i = 1; i <= m; i++) on[x][i]++;
on[x][y]--;
}
else if(tp=='R'){
for(int i = 1; i <= n; i++) on[i][y]--;
for(int i = 1; i <= m; i++) on[x][i]--;
on[x][y]++;
}
else{
int x2, y2; cin >> x2 >> y2;
if(x2<x) swap(x, x2);
if(y2<y) swap(y, y2);
bool ok = true;
for(int i = x; i <= x2; i++){
for(int j = y; j <= y2; j++) if(!on[i][j]) ok = false;
}
if(ok) 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