Set (STL) problems solve
1.#include <bits/stdc++.h>
using namespace std;
int main()
{
set <int> s;
int q,n,x,y,z;
cin >> q;
while(q--)
{
int n;
cin >> n;
if(n == 1)
{
cin >> x;
s.insert(x);
}
if(n == 2)
{
cin >> y;
auto it = s.find(y);
if(it != s.end())
{
s.erase(it);
}
}
if(n == 3)
{
cin >> z;
auto it = s.find(z);
if(it != s.end())
{
cout << "Yes\n";
} else {
cout << "No\n";
}
}
}
}
Comments
Post a Comment