Cod sursa(job #2530044)

Utilizator BlueLuca888Girbovan Robert Luca BlueLuca888 Data 24 ianuarie 2020 12:26:48
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.12 kb
#include <iostream>
#include <fstream>
#include <vector>
#define DIM 638919

using namespace std;

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

int n, tip, x, i;
int ok, st, dr;
vector <int>v[DIM];

int main (){
      fin>>n;
      for(int pas=1; pas<=n; pas++){
            fin>>tip>>x;
            i=x%DIM;
            st=0;
            dr=v[i].size()-1;

            if(tip == 1){
                  ok=0;
                  for(int j=st; j<=dr; j++)
                        if(v[i][j] == x)
                              ok=1;
                  if(ok == 0)
                        v[i].push_back(x);

            }else if(tip == 2){
                  for(int j=st; j<=dr; j++)
                        if(v[i][j] == x){
                              swap(v[i][j], v[i][dr]);
                              v[i].pop_back();
                        }
            }else{
                  ok=0;
                  for(int j=st; j<=dr; j++)
                        if(v[i][j] == x)
                              ok=1;
                  fout<<ok<<"\n";
            }
      }
      return 0;
}