Pagini recente » Cod sursa (job #1685005) | Clasament ojiprep1 | Cod sursa (job #1869714) | Cod sursa (job #117095) | Cod sursa (job #1412445)
#include <fstream>
#include <vector>
#include <set>
using namespace std;
#define modullo 49157
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector<vector<short> > v(modullo+4);
short fi(unsigned short r,unsigned short c){
for(int i=v[r].size()-1;i>=0;i--){
if(v[r][i]==c)return i;
}
return -1;
}
void hin(unsigned short r,unsigned short c){
if(fi(r,c)==-1)v[r].push_back(c);
}
void hout(unsigned short r,unsigned short c){
int i= fi(r,c);
if(i!=-1){
swap(v[r][i],v[r].back());
v[r].pop_back();
}
}
int main()
{
int n,x;
unsigned k,c,r;
fin>>n;
for(int i=0;i<n;i++){
fin>> k>> x;
r=x%modullo;
c=x/modullo;
if(k==1)hin(r,c);
else if(k==2)hout(r,c);
else{
if(fi(r,c)!=-1)fout<<"1"<<'\n';
else fout<<'0'<<'\n';
}
}
return 0;
}