Cod sursa(job #2974046)

Utilizator divadddDavid Curca divaddd Data 2 februarie 2023 23:11:17
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.17 kb
#include <bits/stdc++.h>
#define MOD 30017
using namespace std;
int n,op,x;
vector<int> mp[MOD];

ifstream fin("hashuri.in");
ofstream fout("hashuri.out");

int main()
{
    fin >> n;
    while(n--){
        fin >> op >> x;
        if(op == 1){
            bool ok = true;
            for(auto it: mp[x%MOD]){
                if(it == x){
                    ok = false;
                    break;
                }
            }
            if(ok)
                mp[x%MOD].push_back(x);
        }else if(op == 2){
            bool ok = false;
            vector<int>::iterator pos;
            for(auto it = mp[x%MOD].begin(); it != mp[x%MOD].end(); it++){
                if(*it == x){
                    pos = it;
                    ok = true;
                    break;
                }
            }
            if(ok){
                mp[x%MOD].erase(pos);
            }
        }else{
            bool ok = false;
            for(auto it: mp[x%MOD]){
                if(it == x){
                    ok = true;
                    break;
                }
            }
            fout << ok << "\n";
        }
    }
    return 0;
}