Cod sursa(job #2085892)

Utilizator Alex18maiAlex Enache Alex18mai Data 10 decembrie 2017 21:14:45
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.17 kb
#include <fstream>
#include <vector>

using namespace std;

ifstream cin ("hashuri.in");
ofstream cout ("hashuri.out");

int MOD = 1000133;

vector <int> v[1001000];

int main() {

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin>>n;

    for (int i=1; i<=n; i++){
        int tip , nr;
        cin>>tip>>nr;
        int caut = nr % MOD;

        if (tip == 1){
            bool ignore = false;
            for (auto &x : v[caut]){
                if (x == nr){
                    ignore = true;
                    break;
                }
            }
            if (!ignore){
                v[caut].push_back(nr);
            }
        }

        if (tip == 2){
            vector <int> now;
            for (auto &x : v[caut]){
                if (x != nr){
                    now.push_back(x);
                }
            }
            v[caut] = now;
        }

        if (tip == 3){
            bool gasit = false;
            for (auto &x : v[caut]){
                if (x == nr){
                    gasit = true;
                    break;
                }
            }
            cout<<gasit<<'\n';
        }

    }

    return 0;
}