We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */set<int>s;intQ;cin>>Q;for(inti=0;i<Q;i++){pair<int,int>query;cin>>query.first>>query.second;intx=query.first;inty=query.second;if(x==1){s.insert(y);}elseif(x==2){s.erase(y);}elseif(x==3){set<int>::iteratorit=s.find(y);it==s.end()?cout<<"No\n":cout<<"Yes\n";}}return0;}
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<set>#include<algorithm>usingnamespacestd;intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */intQ;cin>>Q;set<int>s;for(inti=0;i<Q;i++){intqueryType,queryValue;cin>>queryType>>queryValue;if(queryType==1){s.insert(queryValue);}elseif(queryType==2){s.erase(queryValue);}elseif(queryType==3){set<int>::iteratorit=s.find(queryValue);if(it!=s.end()){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}}return0;}
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<set>#include<algorithm>usingnamespacestd;intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */set<int>s;intQ;cin>>Q;for(inti=0;i<Q;i++){intquery;intx;cin>>query;cin>>x;switch(query){case1:s.insert(x);break;case2:s.erase(x);break;case3:autoitr=s.find(x);if(itr!=s.end()){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}break;}}return0;}
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<set>#include<algorithm>usingnamespacestd;intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */size_tQ,y,x;cin>>Q;set<size_t>numbers;for(;Q>0;Q--){cin>>y>>x;switch(y){case1:numbers.insert(x);break;case2:numbers.erase(x);break;case3:{autoit=numbers.find(x);cout<<(it==numbers.end()?"No":"Yes")<<endl;}break;}}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
include
include
include
include
using namespace std;
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */
int queries; cin >> queries; cin.ignore();
}