Cod sursa(job #1862554)

Utilizator DoubleNyNinicu Cristian DoubleNy Data 30 ianuarie 2017 01:27:13
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.59 kb
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart=clock();
#define time (double)(clock() - tStart)/CLOCKS_PER_SEC;
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
//
#define mod 1000000
int n;
vector <int> vct[1000001];

int main(){
            freopen("hashuri.in", "r", stdin);
            freopen("hashuri.out", "w", stdout);
            scanf("%d", &n);
            for(int i = 0; i < n; i++){
                    int tp, x;
                    scanf("%d %d",&tp,&x);
                    if(tp == 1){
                        int k = x % mod;
                        vct[k].push_back(x);
                    }
                    if(tp == 2){
                        int k = x % mod;
                        for(int j = 0; j < vct[k].size(); j++)
                        if(vct[k][j] == x){
                            vct[k][j] = -1;
                            break;
                        }
                    }
                    if(tp == 3){
                        int k = x % mod;
                        bool notFound = 1;
                        for(int j = 0; j < vct[k].size(); j++)
                        if(vct[k][j] == x){
                            printf("%d\n", 1);
                            notFound = 0;
                            break;
                        }
                        if(notFound)
                                printf("%d\n", 0);
                    }
            }
}