D - Garbage Removal
题目链接:https://atcoder.jp/contests/abc406/tasks/abc406_d
题意:
爆二维矩阵的操作题,用map<int,set
int h,w,n;
int a[maxn];
int b[maxn];
map<int,set<int>>r,c;
void solve(){
cin>>h>>w>>n;
rep(i,1,n){
int x,y;cin>>x>>y;
a[x]++;
b[y]++;
r[x].insert(y);
c[y].insert(x);
}
int q;cin>>q;
while(q--){
int opt;cin>>opt;
if(opt==1){
int x;cin>>x;
cout<<r[x].size()<<endl;
for(auto y:r[x]){
c[y].erase(x);
}
r[x].clear();
}else{
int y;cin>>y;
cout<<c[y].size()<<endl;
for(auto x:c[y]){
r[x].erase(y);
}
c[y].clear();
}
}
}

浙公网安备 33010602011771号