Cod sursa(job #653747)

Utilizator an_drey_curentandreycurent an_drey_curent Data 28 decembrie 2011 20:00:26
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.73 kb
#include <stdio.h>					//619999
#include <vector>
using namespace std;

vector <int> a[620000];

int main()
{
	freopen("hashuri.in","r",stdin);
	freopen("hashuri.out","w",stdout);
	int n,i,j,opt,x,nr=619999,coord,ok,cheie,size;
	
	scanf("%d", &n);

	for (i=1;i<=n;i++){
		scanf("%d %d", &opt, &x);
		cheie=x%nr;
		
		ok=0;
		size=a[cheie].size();
		for (j=0;j<size;j++)
			if (a[cheie][j]==x){
				ok=1;
				coord=j;
			}

		if (ok)
			j=coord;

		if (opt==1 && j==size)
			a[cheie].push_back(x);
		else
		if (opt==2 && j!=size){
			a[cheie][j]=a[cheie][size-1];
			a[cheie].pop_back();
		}
		else
		if (opt==3)
		{
			if (j==size)
				printf("0\n");
			else 
				printf("1\n");
		}

	}

	return 0;
}