Pagini recente » Cod sursa (job #708968) | Cod sursa (job #2521834) | Cod sursa (job #974880) | Cod sursa (job #2407944) | Cod sursa (job #2487640)
#include <fstream>
#include <vector>
using namespace std;
int const NM = 1e6 + 1 , P = 666013;
ifstream f ("hashuri.in");
ofstream g ("hashuri.out");
vector <int> v [P + 1];
vector <int> :: iterator it;
void add (int x){
v [x % P] . push_back (x);
}
void del (int x){
for (int i = 0 ; i < v [x % P] . size () ; ++ i)
if (v [x % P][i] == x){
swap (v [x % P][i] , v [x % P][v [x % P] . size () - 1]);
v [x % P] . pop_back ();
return;
}
}
bool find_ (int x){
for (it = v [x % P] . begin () ; it != v [x % P] . end () ; ++ it)
if (*it == x)
return true;
return false;
}
int main()
{
int n;
f >> n;
while (n --){
int op , x;
f >> op >> x;
if (op == 1)
add (x);
if (op == 2)
del (x);
if (op == 3)
g << find_ (x) << '\n';
}
return 0;
}