题解:AT_abc403_c [ABC403C] 403 Forbidden
这道题可以用 STL 容器中的 set 来解。因为 set 中有一个名叫 count 的内置函数,能统计集合中指定元素的出现次数。在本题中,可以考虑建一个 set 数组,用于记录用户
代码:
#include<bits/stdc++.h>
using namespace std;
int n,m,q,x,y;
bool used[200010];
set<int> a[200010];
int main()
{
cin>>n>>m>>q;
while(q--)
{
int op;
cin>>op;
if(op==1)
{
cin>>x>>y;
a[x].insert(y);
}
else if(op==2)
{
cin>>x;
used[x]=1;
}
else if(op==3)
{
cin>>x>>y;
if(a[x].count(y)>0||used[x]==1)
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}
}
return 0;
}