Cod sursa(job #529531)

Utilizator dornescuvladVlad Eugen Dornescu dornescuvlad Data 5 februarie 2011 13:58:37
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.91 kb
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>

using namespace std;

const char iname[] = "hashuri.in";
const char oname[] = "hashuri.out";
const int  mod     = 102356;

ifstream fin(iname);
ofstream fout(oname);

vector<int> H[mod];
int n, i, operation, x;


int main()
{
	fin >> n;
	for(i = 1; i <= n; i ++)
	{
		fin >> operation >> x;
		if(operation == 1)
			if(find(H[x % mod].begin(), H[x % mod].end(),  x) == H[x % mod].end())
				H[x % mod].push_back(x);
			
		
		if(operation == 2)
			if(find(H[x % mod].begin(), H[x % mod].end(),  x) != H[x % mod].end())
			{
				vector<int>::iterator it = find(H[x % mod].begin(), H[x % mod].end(),  x);
				H[x % mod].erase(it);
			}
	
		if(operation == 3)
		{
			if(find(H[x % mod].begin(), H[x % mod].end(),  x) == H[x % mod].end())
				fout << "0\n";
			else
				fout << "1\n";
		}
	}
	return 0;
}