Cod sursa(job #1954574)

Utilizator MihaelaCismaruMihaela Cismaru MihaelaCismaru Data 5 aprilie 2017 15:11:25
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.16 kb
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");

vector<int> v[100009];

int n,i,op,x,z,ok,j,a;

int main(){
    in >> n;
    for( i = 1; i <= n; i ++ ){
        in >> op >> x;
        z = x % 100009;
        if( op == 1){
            ok = 0;
            for( j = 0; j < v[z].size(); j ++ ) {
                if( v[z][j] == x ){
                    ok = 1;
                }
            }
            if( ok == 0 ){
                v[z].push_back(x);
            }
        }
        if( op == 2 ){
            ok = 0;
            for( j = 0; j < v[z].size(); j ++ ) {
                if( v[z][j] == x ){
                    ok = 1;
                    a = j;
                }
            }
            if( ok == 1 ){
                swap( v[z][a] , v[z][v[z].size()-1]);
                v[z].pop_back();
            }
            
        }
        if( op == 3 ){
            ok = 0;
            for( j = 0; j < v[z].size(); j ++ ) {
                if( v[z][j] == x ){
                    ok = 1;
                }
            }
            out << ok << "\n";
        }
    }
    
    return 0;
}