Cod sursa(job #1234091)

Utilizator vtt271Vasile Toncu vtt271 Data 26 septembrie 2014 18:11:47
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.81 kb
#include <fstream>
#include <vector>

using namespace std;

#define ID 1000000

vector <int> HASH[1000000];

int isIn(int x)
{
    for(int i = 0; i < HASH[x%ID].size()){
        if( HASH[x%ID][i] == x ) return i;
    }

    return -1;
}

int main()
{
    ifstream inFile("hash.in");
    ofstream outFile("hash.out");

    int n;
    inFile >> n;

    int op, x;

    while(n--){
        inFile >> op >> x;
        if( op == 1 ){
            int aux = isIn(x);
            if( aux == -1 ) HASH[x%ID].push_back(x);
        }
        if( op == 2 ){
            int aux = isIn(x);
            if(aux != -1){
                HASH[x%ID].erase(aux);
            }
        }
        if( op == 3 ){
            if( isIn(x) == -1) outFile << 0;
            else outFile << 1;
        }
    }

}