Pagini recente » Cod sursa (job #515457) | Cod sursa (job #3266179) | Cod sursa (job #2908001) | Cod sursa (job #3179270) | Cod sursa (job #2661510)
#include <iostream>
#include <stdio.h>
#include <vector>
#include <ctype.h>
#define MOD 1000000
using namespace std;
short lim[MOD];
vector<short>h[MOD];
FILE *fin, *fout;
int readInt(){
int n;
char ch;
while(!isdigit(ch = fgetc(fin)));
n=ch - '0';
while(isdigit(ch = fgetc(fin))){
n = n * 10 + ch - '0';
}
return n;
}
int main()
{
int n, op, x, i, j;
fin=fopen("hashuri.in", "r");
n = readInt();
fout=fopen("hashuri.out", "w");
for(i = 0; i < n; i++){
op = readInt();
x = readInt();
if(op == 1){
h[x % MOD].push_back(x / MOD);
lim[x % MOD]++;
}else if(op == 2){
j = 0;
while((j < lim[x % MOD]) && (h[x % MOD][j] != (x / MOD))){
j++;
}
if(j < lim[x % MOD]){
h[x % MOD].erase(h[x % MOD].begin() + j);
lim[x % MOD]--;
}
}else{
j = 0;
while((j < lim[x % MOD]) && (h[x % MOD][j] != (x / MOD))){
j++;
}
if(j < lim[x % MOD]){
fprintf(fout, "1\n");
}else{
fprintf(fout, "0\n");
}
}
}
fclose(fin);
fclose(fout);
return 0;
}