Cod sursa(job #644387)

Utilizator an_drey_curentandreycurent an_drey_curent Data 6 decembrie 2011 11:30:58
Problema Hashuri Scor 60
Compilator cpp Status done
Runda Arhiva educationala Marime 0.81 kb
#include<vector>
#include<fstream>
#include<iostream>
using namespace std;
vector<long int>v[550000];
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int main()
{
	long int j,i,N,instructiune,numar,cheia;
	f>>N;
	for(i=1;i<=N;i++)
	{
		f>>instructiune;
		f>>numar;
		cheia=numar%549979;
		long int lungime=v[cheia].size();
		for(j=0;j<lungime;j++)
				if(v[cheia][j]==numar)
					break;
		switch(instructiune)
		{
			case 1:
				{
				if(j==lungime)
					v[cheia].push_back(numar);
				break;
				}
			case 2:
				{
				if(j<lungime)
				{
					v[cheia][j]=v[cheia][lungime-1];
					v[cheia].pop_back();
				}
				break;
				}
			case 3:
				{
				if(j==lungime)
					g<<0<<endl;
				else
					g<<1<<endl;
				break;
				}
		}
	}
	f.close();
	g.close();
	return 0;
}