Pagini recente » Cod sursa (job #1645475) | Cod sursa (job #2795825) | Cod sursa (job #1135329) | Cod sursa (job #2674056) | Cod sursa (job #2921387)
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <bitset>
#pragma GCC optimize("Ofast")
using namespace std;
pair <int,int> v[1000001];
int vf[1000001],cnt;
bitset <1000001> vf1;
const int dim=1<<17;
char next_ch()
{
static char buff[dim];
static int bp=dim;
if(bp==dim)
{
bp=0;
fread(buff,1,dim,stdin);
}
return buff[bp++];
}
void get(int &a)
{
a=0;
char ch;
do
{
ch=next_ch();
}
while(ch<'0'&&'9'<ch);
do
{
a=a*10+ch-'0';
ch=next_ch();
}
while('0'<=ch&&ch<='9');
}
int cautbin(int val)
{
int r=0,pas=1<<19;
while(pas)
{
if(r+pas<=cnt&&vf[r+pas]<=val)
r+=pas;
pas/=2;
}
return r;
}
int main()
{
ios::sync_with_stdio(0);
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
int n,i,x;
get(n);
for(i=1; i<=n; i++)
{
get(v[i].first);
get(v[i].second);
vf[++cnt]=v[i].second;
}
sort(vf+1,vf+n+1);
cnt=0;
for(i=1; i<=n; i++)
if(vf[i]!=vf[i-1])
vf[++cnt]=vf[i];
for(i=1; i<=n; i++)
{
x=cautbin(v[i].second);
if(v[i].first==1)
vf1[x]=1;
else if(v[i].first==2)
vf1[x]=0;
else
cout<<vf1[x]<<'\n';
}
return 0;
}