Cod sursa(job #2194211)

Utilizator bigmixerVictor Purice bigmixer Data 12 aprilie 2018 16:48:27
Problema Hashuri Scor 60
Compilator cpp Status done
Runda Arhiva educationala Marime 0.92 kb
#include<iostream>
#include<fstream>
#include<vector>
const int noi=6e5;
using namespace std;

ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int t,x;
int mod;
bool shit;
int n;
vector<int>ham[noi];

int main(){
    fin>>n;
    for(int i=1;i<=n;i++){
    fin >> t >> x;
    mod=x%noi;
    if(t==1){
      shit=0;
      for(int i=0; i<ham[mod].size(); ++i)
        if(ham[mod][i]==x){
        shit=1;
        break;
      }

     if(shit==0) ham[mod].push_back(x);
    }
    if(t==2){
      shit=0;
      for(int i=0; i<ham[mod].size(); ++i)
          if(ham[mod][i]==x){
              ham[mod].erase(ham[mod].begin()+i);
              break;
          }
      }
      if(t==3){
         shit=0;
         for(int i=0; i<ham[mod].size(); ++i)
            if(ham[mod][i]==x){
               shit=1;
               break;
            }
          fout<<shit<<endl;
          }
      }
}