Cod sursa(job #1164561)

Utilizator UVS_Elfus_Deneo_KiraUVS-Elfus-Dutzul-Kira UVS_Elfus_Deneo_Kira Data 2 aprilie 2014 09:59:43
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.27 kb
#include<fstream>
#include<cstdio>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#define FOR(a,b,c) for(int a=b;a<=c;++a)
#include<cstring>
#include<bitset>
#include<cmath>
#include<iomanip>
#include<queue>
#define f cin
#define g cout
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define bit 20
#define inf (1<<30)
#define base 256
#define ba 255
#define N 500100
#define mod  666013
#define inu "hashuri.in"
#define outu "hashuri.out"
using namespace std;
ifstream f(inu);
ofstream g(outu);
//int dx[]={0,0,0,1,-1};
//int dy[]={0,1,-1,0,0};
vector<int> H[mod];
int n,tip,x;
void insert(int x)
{
    int mo=x%mod;
    H[mo].push_back(x);
}
int find(int x)
{
    int mo=x%mod;
    for(int i=0;i<H[mo].size();++i)
    if(H[mo][i]==x)
    return 1;
    return 0;
}
void del(int x)
{
    int mo=x%mod;
    for(int i=0;i<H[mo].size();++i)
    if(H[mo][i]==x)
    {
        H[mo][i]=0;
        return;
    }
    return;
}
int main ()
{
    f>>n;
    FOR(i,1,n)
    {
        f>>tip>>x;
        if(tip==1)
        if(!find(x))
            insert(x);
        if(tip==2)
            del(x);
        if(tip==3)
            g<<find(x)<<"\n";
    }
    return 0;
}