Cod sursa(job #2626983)

Utilizator Sho10Andrei Alexandru Sho10 Data 9 iunie 2020 12:14:19
Problema Hashuri Scor 60
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.25 kb
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define modul 998244353
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hz vector<ll> :: iterator
using namespace std;
ll q,t,x,h=666013;
vector<ll>v[866013];
vector<ll> :: iterator find(ll x){
ll a=x%h;
for(vector<ll> :: iterator it=v[a].begin();it!=v[a].end();it++)
{
    if(*it==x){
        return it;
    }
}
return v[a].end();
}
void add(ll x){
if(find(x)==v[x%h].end()){
    v[x%h].pb(x);
}
}
void del(ll x){
auto it=find(x);
if(it!=v[x%mod].end()){
    v[x%mod].erase(it);
}
}
int32_t main(){
CODE_START;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
cin>>q;
while(q--){
    cin>>t>>x;
    if(t==1){
        add(x);
    }else if(t==2){
    del(x);
    }else {
    if(find(x)!=v[x%h].end()){
        cout<<1<<endl;
    }else cout<<0<<endl;
}
}
}