Pagini recente » Cod sursa (job #1450408) | Cod sursa (job #2881723) | Cod sursa (job #362256) | Cod sursa (job #2885955) | Cod sursa (job #640586)
Cod sursa(job #640586)
#include <fstream>
#include <vector>
#include <string.h>
#define P 2003
using namespace std;
long n, i, t, v, o;
char st[1000010], gh[2000010];
vector <long> V[P + 10];
inline vector<long>::iterator find_value(long x) {
long aux = v % P;
vector<long>::iterator it;
for (it = V[aux].begin(); it != V[aux].end(); ++it)
if (*it == x)
return it;
return V[aux].end();
}
int main() {
//ifstream fin("hashuri.in");
//ofstream fout("hashuri.out");
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
//fin>>n;
scanf("%ld\n", &n);
//gets(gh);
for (i = 1; i <= n; ++i) {
gets(gh);
long h = 0;
t = 0, v = 0;
while (gh[h] != ' ')
t *= 10, t += (long)(gh[h] - '0'), ++h;
++h;
while (h < strlen(gh))
v *= 10, v += (long)(gh[h] - '0'), ++h;
//t = 1;
//v = i;
if (t == 1) {
long aux = v % P;
long S = V[aux].size();
long ok = 0;
for (long j = 0; j < S; ++j)
if (V[aux][j] == v) {
ok = 1;
break;
}
if (!ok) V[aux].push_back(v);
}
if (t == 2) {
long aux = v % P;
vector<long>::iterator it = find_value(v);
if (it != V[aux].end())
V[aux].erase(it);
//V[aux].erase(v);
}
if (t == 3) {
long aux = v % P;
long S = V[aux].size();
long ok = 0;
for (long j = 0; j < S; ++j)
if (V[aux][j] == v) {
//fout<<"1"<<"\n";
st[o++] = '1';
st[o++] = '\n';
ok = 1;
break;
}
if (!ok) {
//fout<<"0"<<"\n";
st[o++] = '0';
st[o++] = '\n';
}
}
}
printf("%s", st);
return 0;
}