Sets-STL

  • + 0 comments

    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();

    set<int> s;
    
    for (int i = 0; i < queries; i++) {
        int type, num;
    
        cin >> type >> num;
    
        auto it = s.find(num);
    
        switch (type) {
            case 1:
                s.insert(num);
                break;
            case 2:
                s.erase(num);
                break;
            case 3:
                if (it != s.end() && *it == num) {
                    cout << "Yes" << endl;
                } else {
                    cout << "No" << endl;
                }
                break;
            default:
                break;
        }
    }
    return 0;
    

    }