Pagini recente » Cod sursa (job #1537462) | Cod sursa (job #629187) | Cod sursa (job #2540200) | Cod sursa (job #909140) | Cod sursa (job #3159493)
#include <bits/stdc++.h>
using namespace std;
const int BAZA = 37;
const int MOD = 666013;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
vector <int> v[MOD];
int hashuri( int a ){
int hsh = 0;
while( a > 0 ){
hsh = (hsh * BAZA + a%10) % MOD;
a /= 10;
}
return hsh;
}
int main()
{
int n;
in >> n;
for( int i = 0; i < n; i++ ){
int cer, a;
in >> cer >> a;
int hsh = hashuri(a);
auto it = find( v[hsh].begin(), v[hsh].end(), a);
if( cer == 1 && it == v[hsh].end()){
v[hsh].push_back(a);
}
else if( cer == 2 && it != v[hsh].end()){
v[hsh].erase(it);
}
else if( cer == 3 && it != v[hsh].end() )
out << 1 << "\n";
else if ( cer == 3 )
out << 0 << "\n";
}
return 0;
}