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.
+ 0 comments #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <set> #include <algorithm> using namespace std; #define ADD 1 #define DELETE 2 #define PRINT 3 int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int q {0} ; int y {0} ; int x {0} ; set<int> st ; set<int>::iterator itr = st.end() ; cin >> q ; for( int i = 0; i < q; i++ ) { cin >> y ; cin >> x ; switch( y ) { case ADD: st.insert( x ) ; break ; case DELETE: itr = st.find( x ) ; if( itr != st.end() ) { st.erase( x ) ; } else { } break ; case PRINT: itr = st.find( x ) ; if( itr != st.end() ) { cout << "Yes" << endl ; } else { cout << "No" << endl ; } break ; default: // Do nothing. break ; } } return 0; }
+ 0 comments include
include
include
include
include
include
using namespace std;
int main() { int iCount; set ss; cin >> iCount; for (int i=0; i> type >> query; switch (type){ case 1: ss.insert(query); break; case 2: ss.erase(query); break; case 3: cout << (ss.find(query) == ss.end() ? "No" : "Yes") << endl; break; } }
return 0; }
+ 0 comments Great
+ 1 comment #include <bits/stdc++.h> using namespace std; int main(){ int p,q,r,x,i,k; set <int> st; cin>>k; for(i=0;i<k;i++){ cin>>x; if(x==1){ cin>>p; st.insert(p); } if(x==2){ cin>>q; st.erase(q); } if(x==3){ cin>>r; auto pos = st.find(r); if(pos!=st.end()) cout<<"Yes\n"; else cout<<"No\n"; } } printf("\n"); return 0; }
+ 1 comment why 10 and 12 testcases are not passed ?
include
using namespace std; int main() { set s; int t,x,y; cin>>t; while(t--) { cin>>y; cin>>x;
if(y==1) s.insert(x); if(y==2) s.erase(x); if(y==3) { set<int>::iterator it=s.find(x); if(x==*(it)) cout<<"Yes"<<endl; else cout<<"No"<<endl; } } return 0;
}
Load more conversations
Sort 311 Discussions, By:
Please Login in order to post a comment