Pagini recente » Rating vasi maruseac (vasiion) | Cod sursa (job #2864418) | Cod sursa (job #1120355) | Cod sursa (job #1942756) | Cod sursa (job #2835728)
#include <bits/stdc++.h>
#define MOD 666013
#define NMAX 1000000
#define LIM 131072
/// TONI BO$$ was here
/// #MLC
using namespace std;
char BUF[LIM];
int poz;
inline char getChar(){
poz++;
if(poz>=LIM){
fread(BUF,LIM,1,stdin);
poz=0;
}
return BUF[poz];
}
inline int getNr(){
int r=0, semn=1;
char ch=getChar();
while(isdigit(ch)==0 && ch!='-') ch=getChar();
if(ch=='-'){
semn=-1;
ch=getChar();
}
while(isdigit(ch)!=0){
r=r*10+semn*(ch-'0');
ch=getChar();
}
return r;
}
struct nod
{
int x;
nod *next;
}nodes[NMAX + 1], r[NMAX + 1];
int main()
{
int x, n, m, i, q;
nod *cursor;
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
n = getNr();
m = 0;
///(*cursor).next = cursor->next
for(i = 1; i <= n; i++)
{
q = getNr();
x = getNr();
switch(q)
{
case 1: m++;
nodes[m].next = r[x % MOD].next;
r[x % MOD].next = &nodes[m];
nodes[m].x = x;
break;
case 2: cursor = &r[x % MOD];
while(cursor->next != nullptr && (cursor->next)->x != x)
cursor = cursor->next;
if(cursor->next != nullptr)
cursor->next = (cursor->next)->next;
break;
case 3: cursor = &r[x % MOD];
while(cursor != nullptr && cursor->x != x)
cursor = cursor->next;
if(cursor != nullptr)
printf("1\n");
else
printf("0\n");
break;
}
}
return 0;
}