Cod sursa(job #1233038)

Utilizator andreey_047Andrei Maxim andreey_047 Data 24 septembrie 2014 15:51:13
Problema Hashuri Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.82 kb
#include <iostream>
#define in "hashuri.in","r",stdin
#define out "hashuri.out","w",stdout
#include <cstdio>
#include <vector>
#define nmax 100001
using namespace std;
int n;
vector<int>G[nmax];
int cauta(long long x , int poz){
for(int i = 0; i < G[poz].size();i++)
    if(G[poz][i] == x) return 1;
 return 0;
}
void sterge(long long x , int poz){
    int ok=1;
 for(int i = 0;i < G[poz].size()&&ok;i++)
 if(G[poz][i] == x) {G[poz][i]=-1;ok=0;}
}
int main(){
    int cod,x,i;
    freopen(in);
    freopen(out);
     scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&cod,&x);
        if(cod == 1) G[x%n].push_back(x);
        else if(cod == 2) sterge(x,x%n);
        else if(cod == 3){
            if(cauta(x,x%n)) cout <<"1\n";
            else cout<<"0\n";
        }
    }
    return 0;
}