You are viewing a single comment's thread. Return to all comments →
Have the problem solved, but do not know why if using
if (*itr == x) cout << "Yes" << endl;
would fail test case #10 and #12. I think it should be the same as
if (itr != s.end()) cout << "Yes" << endl;
Any hints?
full code as follows:
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int q, n, i, j, y, x; cin >> q; set<int> s; for (i=0;i<q;i++) { cin >> y >> x; if (y == 1) { s.insert(x); } if (y ==2) { s.erase(x); } if (y == 3) { set<int>::iterator itr = s.find(x); if (itr != s.end()) cout << "Yes" << endl; //if (*itr == x) cout << "Yes" << endl; else cout << "No" << endl; } } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Sets-STL
You are viewing a single comment's thread. Return to all comments →
Have the problem solved, but do not know why if using
would fail test case #10 and #12. I think it should be the same as
Any hints?
full code as follows: