Cod sursa(job #1329796)

Utilizator asavoaeigeoAsavoaei Georgiana asavoaeigeo Data 29 ianuarie 2015 20:56:26
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector <int>v[666013];
vector<int>:: iterator it;
const int mod=666013;

void o1(int x)
{
    v[x%mod].push_back(x);
}

void o2(int x)
{
    int rest=x%mod;
    for(it=v[rest].begin();it!=v[rest].end();it++)
       if(*it==x)
          { *it=v[rest].back();
             v[rest].pop_back();
             it--;
          }
}
int o3(int x)
{
    int rest=x%mod;
    for(it=v[rest].begin();it!=v[rest].end();it++)
       if(*it==x) return 1;
    return 0;
}


int main()
{
    int n,op,x;
    fin>>n;
    while(n!=0)
    { fin>>op>>x;
      if(op==1) o1(x);
      else if(op==2) o2(x);
         else fout<<o3(x)<<"\n";
        n--;
    }
    return 0;
}