Nu aveti permisiuni pentru a descarca fisierul grader_test6.in
Cod sursa(job #773664)
Utilizator | Data | 2 august 2012 12:30:31 | |
---|---|---|---|
Problema | Hashuri | Scor | 60 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.86 kb |
#include <fstream>
#include <vector>
#define mod 666013
#define pb push_back
using namespace std;
vector <int> h[mod];
vector <int> :: iterator it;
int i, ind, n, op, x;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector <int> :: iterator find_v(int x)
{
for (it = h[ind].begin() ; it != h[ind].end() ; it++)
if (*it==x) return it;
return it;
}
void insert_v(int x) {
if (it==h[ind].end()) h[ind].pb(x);
}
void erase_v(int x)
{
if (it!=h[ind].end()) h[ind].erase(it);
}
void write_v(int x)
{
if(it==h[ind].end()) g<<"0"<<endl; else g<<"1"<<endl;
}
int main()
{
f>> n;
for ( i=1;i<=n;i++)
{
f>> op>> x;
ind=x%mod;
it=find_v(x);
if (op==1) insert_v(x);
if (op==2) erase_v(x);
if (op==3) write_v(x);
}
f.close();
g.close();
}