Cod sursa(job #371135)

Utilizator nusmaibunkeleviprofesor cicalescu nusmaibunkelevi Data 3 decembrie 2009 21:45:56
Problema Hashuri Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.58 kb
#include<stdio.h>
#include<stdlib.h>

#define NM 1000001
int n,v[NM];

int main(){
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
int i,m,op,x;
char s[15],*p;
scanf("%d\n",&m);
while(m--){
	fgets(s,14,stdin);
	p=s;
	op=atoi(p);p+=2;x=atoi(p);
	switch(op){
		case 1:
			   n++;v[n]=x;
			   break;
		case 2:i=1;
			   while(i<=n&&v[i]!=x) i++;
			   if(i<=n){
				while(i<n) v[i]=v[i+1],i++;
				n--;
				}
			   break;
		case 3:i=1;
			   while(i<=n&&v[i]!=x) i++;
			   if(i<=n) printf("1\n");
			   else printf("0\n");
		}
	}
return 0;
}