Pagini recente » Cod sursa (job #22879) | Cod sursa (job #2854568) | Cod sursa (job #1622366) | Cod sursa (job #245867) | Cod sursa (job #2145928)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
const int P = 1000003;
vector < int > L[P];
int Q;
inline void Push(int x)
{
int r;
r = x % P;
L[r] . push_back(x);
}
inline void Pop(int x)
{
int r , dim;
r = x % P;
dim = L[r] . size();
for(unsigned int i = 0 ; i < dim ; i++)
if(L[r][i] == x)
{
L[r][i] = L[r][dim - 1];
L[r] . pop_back();
}
}
inline bool Find(int x)
{
int r;
r = x % P;
for(auto i : L[r])
if(i == x)
return true;
return false;
}
int main()
{
int op , x;
fin >> Q;
while(Q -- )
{
fin >> op >> x;
if(op == 1)
Push(x);
else if(op == 2)
Pop(x);
else fout << Find(x) << "\n";
}
fin.close();
fout.close();
return 0;
}