D - Garbage Removal

题目链接:https://atcoder.jp/contests/abc406/tasks/abc406_d

题意:

爆二维矩阵的操作题,用map<int,set>r,c;存

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();
        }
    }
}
posted @ 2025-05-17 21:49  Marinaco  阅读(21)  评论(0)    收藏  举报
//雪花飘落效果