Cod sursa(job #527633)

Utilizator Catah15Catalin Haidau Catah15 Data 31 ianuarie 2011 22:49:53
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.78 kb
#include <fstream>
#include <vector>
#include <iostream>
#define MOD 666013
using namespace std;


vector <int> v[MOD + 2];


int search(long long x)
{
	for(unsigned int i = 0; i < v[x % MOD].size(); ++i)
		if(v[x % MOD][i] == x)
			return (i + 1);
		
	return 0;
}


int main()
{
	ifstream f("hashuri.in");
	ofstream g("hashuri.out");
	
	int n;
	
	f >> n;
	
	for(int i = 1; i <= n; ++i)
	{
		
		long long x;
		short type;
		
		f >> type >> x;
		
		if(type == 1)
			if(!search(x))
				v[x % MOD].push_back(x);
		
		
			
		if(type == 2)
		{	
			int c = search(x);
			
			if(c)
				v[x % MOD][c - 1] = -1;
			
		}
			
		if(type == 3)
			if(search(x))
				g << "1\n";
			else 
				g << "0\n";
	}
	
	
	f.close();
	g.close();
	
	return 0;
	
}