Pagini recente » Cod sursa (job #2983907) | Cod sursa (job #1619194) | Cod sursa (job #873481) | Cod sursa (job #2515796) | Cod sursa (job #2885957)
/*#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
#define k 666013
vector <int> hashh[k+5];
int main()
{
int j,nr,i,ok,clasa, x,y;
f>>nr;
for(j=0;j<nr;j++)
{
f>>x;
f>>y;
ok=0;
clasa=y%k;
for(int i=0;i<hashh[clasa].size();i++)
{
if( hashh[clasa][i]==y)
{
ok=1;
break;
}
}
if (x==1)
{
if(ok==0)
{
hashh[clasa].push_back(y);
}
}
else
{
if(x==2)
{
if(ok==1)
{
swap(hashh[clasa][i], hashh[clasa].back());
hashh[clasa].pop_back();
}
}
else
{
if(ok == 1)
{
cout<<1<<'\n';
}
else
{
cout<<0<<'\n';
}
}
}
}
return 0;
}
*/
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
#define k 666013
vector <int> hashh[k+2];
int main()
{
int n, i, j, x, y, clasa, poz;
bool ok;
f>>n;
for(i = 1; i <= n; i++)
{
f>>y>>x;
ok = 0;
clasa = x % k;
for(j = 0; j < hashh[clasa].size(); j++)
{
if(hashh[clasa][j] == x)
{
ok = 1;
break;
}
}
if(y == 1)
{
if(ok == 0)
hashh[clasa].push_back(x);
}
else
{
if(y == 2)
{
if(ok == 1)
{
swap(hashh[clasa][j],hashh[clasa].back());
hashh[clasa].pop_back();
}
}
else
{
g<<ok<<endl;
}}
}
return 0;
}