Cod sursa(job #653731)

Utilizator an_drey_curentandreycurent an_drey_curent Data 28 decembrie 2011 19:34:20
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.72 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;
	scanf("%d", &n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&opt);
		scanf("%d",&x);
		cheie=x%nr;
		ok=0;
		for (j=0;j<a[cheie].size();j++)
			if (a[cheie][j]==x){
				ok=1;
				coord=j;
			}
		if (ok)
			j=coord;
		if (opt==1 && j==a[cheie].size())
			a[cheie].push_back(x);

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

	return 0;
}