题解:AT_abc406_d [ABC406D] Garbage Removal
本蒟蒻的第一篇题解,如有建议可以告诉我哦~~
话不多说,直接上代码:
#include<bits/stdc++.h>
using namespace std;
int h,w,n;
int x,y,q,op;
set<int>head1[200010],head2[200010];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>h>>w>>n;
for(int i=1;i<=n;i++)
{
cin>>x>>y;
head1[x].insert(y);
head2[y].insert(x);
}
cin>>q;
while(q--)
{
cin>>op>>x;
if(op==1)
{
cout<<head1[x].size()<<endl;
for(int j : head1[x])
{
head2[j].erase(x);
}
head1[x].clear();
}
if(op==2)
{
cout<<head2[x].size()<<endl;
for(int j : head2[x])
{
head1[j].erase(x);
}
head2[x].clear();
}
}
return 0;
}
PS:语文答题思路(该处使用了开门见山的手法,简单直接地给出了代码,反应出了该蒟蒻善良的特点,****)