Cod sursa(job #3130374)

Utilizator theo_scrie_codGhinea Theodor theo_scrie_cod Data 17 mai 2023 17:07:04
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.97 kb
#include <vector>
#include<fstream>
#include<iostream>
using namespace std;

int N, NR;
int modd=666100;
vector<vector<int>> haash;

int find(int x)
{
    for (size_t i = 0; i < haash[x % modd].size(); i++){
        // cout << "seek";
        if (haash[x % modd][i] == x)
            return i;
    }
        // cout <<haash[x % modd].size()<< endl;
    return -3;
}

int main()
{
	ifstream in("hashuri.in");
    ofstream out("hashuri.out");

	int i, tip, x;

	in >> N;
    haash.resize(modd);
	for (i = 1; i <= N; i++) 
	{
		in >> tip >> x;

		if (tip == 1){
            if(find(x) == -3)
                haash[x % modd].push_back(x);
        }
		if (tip == 2) {
            if(find(x) != -3)
                haash[x % modd].erase(haash[x % modd].begin()+find(x));

        }
		if (tip == 3){
            if(find(x) != -3)
                out << "1\n";
            else
                out << "0\n";
        }
        
	}
    

	return 0;
}