Cod sursa(job #989679)

Utilizator BlackLordFMI Alex Oprea BlackLord Data 26 august 2013 11:47:20
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 1.2 kb
#include <fstream>
#include <vector>
#define DIM 1000000
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n, i, x, o, aux, ok, j;
vector<int> a[DIM+10];
int main(){
    f>>n;
    for(int cresc=1; cresc<=n; cresc++)
    {
        f>>o>>x;
        aux=x%DIM;
        if(o==1)
        {
            ok=0;
            for(i=0; i<a[aux].size(); i++)
                if(a[aux][i]==x)
                {
                    ok=1;
                    break;
                }
            if(ok==0)
                a[aux].push_back(x);
        }
        else if(o==2)
        {
            for(i=0; i<a[aux].size(); i++)
                if(a[aux][i]==x)
                {
                    for(j=i+1; j<a[aux].size(); j++)
                        a[aux][j-1]=a[aux][j];
                    a[aux].pop_back();
                    break;
                }
        }
        else
        {
            ok=0;
            for(i=0; i<a[aux].size(); i++)
            {
                if(a[aux][i]==x)
                {
                    ok=1;
                    break;
                }
            }
            g<<ok<<"\n";
        }
    }
    return 0;
}