Cod sursa(job #2910054)

Utilizator KarinaDKarina Dumitrescu KarinaD Data 17 iunie 2022 23:19:59
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.27 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

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

const int E = 168323;
vector <int> h[E];

int main () {
    
    int n, i, c, x;
    
    fin >> n;
    
    for ( i = 0; i < n; i++ ){
        
        fin >> c >> x;
        
        if ( c == 1 ){
            
            int i1 = 0;
            
            while ( i1 < h[x % E].size() && h[x % E][i1] != x )
                i1++;
            
            if ( i1 == h[x % E].size() )
                h[x % E].push_back(x);
                
        }
        
        if ( c == 2 ){
            
            int i1 = 0;
            
            while ( i1 < h[x % E].size() && h[x % E][i1] != x )
                i1++;
            
            if ( i1 != h[x % E].size() ) {
                swap(h[x % E][i1], h[x % E].back());
                h[x % E].pop_back();

            }
        }
        
        if ( c == 3 ){
            
            int i1 = 0;
            
            while ( i1 < h[x % E].size() && h[x % E][i1] != x )
                i1++;
            
            if ( i1 != h[x % E].size() )
                fout << "1\n";
            else
                fout << "0\n";
            
        }
        
    }
    
    return 0;
}