Cod sursa(job #2182543)
| Utilizator | Data | 22 martie 2018 14:23:03 | |
|---|---|---|---|
| Problema | Hashuri | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.72 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int h = 100003;
int q,v,r,op;
vector<int> H[h];
vector<int>::iterator it;
int main()
{
fin>>q;
while(q--) {
fin>>op>>v;
r=v%h;
for(it=H[r].begin(); it!=H[r].end(); it++)
if(*it==v)
break;
if(op==1) {
if(it==H[r].end())
H[r].push_back(v);
} else if(op==2) {
if(it!=H[r].end()) {
*it=H[r].back();
H[r].pop_back();
}
} else {
if(it==H[r].end()) fout<<"0\n";
else fout<<"1\n";
}
}
return 0;
}
