Cod sursa(job #2885578)

Utilizator Emma19Tiu Ema Emma19 Data 6 aprilie 2022 11:40:42
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.95 kb
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
#define k 666013
vector <int> h[k+3];
int main()
{
  int n, op, nr, ok ;
  f>>n;
  int i;
  for(i=0;i<n;i++)
  {
      f>>op>>nr;
      int clasa = nr%k;
      if(op==1)
      {
          ok=1;
          for(int j =0 ;j < h[clasa].size() && ok ;j++)
           if(h[clasa][j]==nr)
             ok=0;
          if(ok)
            h[clasa].push_back(nr);

      }
      else
        if(op==2)
      {
          for(int j =0 ;j < h[clasa].size() ;j++)
           if(h[clasa][j]==nr)
           {
               swap(h[clasa][j], h[clasa][h[clasa].size()-1]);
               h[clasa].pop_back();
           }

      }
      else
      {
          ok=0;
          for(int j =0 ;j < h[clasa].size() && ok==0 ;j++)
           if(h[clasa][j]==nr)
             ok=1;
           g<<ok<<'\n';

      }
  }
}