Sets-STL

  • + 0 comments
    int main() {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
        set<int> s;
        int Q;
        cin >> Q;
        for (int i = 0; i < Q; i++) {
          pair<int, int> query;
          cin >> query.first >> query.second;
          int x = query.first;
          int y = query.second;
          if (x == 1) {
            s.insert(y);
          } else if (x == 2) {
            s.erase(y);
          } else if (x == 3) {
            set<int>::iterator it = s.find(y);
            it == s.end() ? cout << "No\n" : cout << "Yes\n";
          }
        }
        return 0;
    }