Pagini recente » Cod sursa (job #2838806) | Cod sursa (job #3296323) | Cod sursa (job #3283810) | Cod sursa (job #3294368) | Cod sursa (job #2405140)
#include <fstream>
#define debug(x) cerr << #x": " << x << "\n"
using namespace std;
const int P1 = 1662803;
const int P2 = 1483733;
const int P3 = 1235711;
const int P4 = 1831381;
const int P5 = 1000033;
long long tableOne [P1];
long long tableTwo [P2];
long long tableThree[P3];
long long tableFour [P4];
long long tableFive [P5];
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
bool isIn(long long number){
int pos[5];
pos[0] = number%P1;
pos[1] = number%P2;
pos[2] = number%P3;
pos[3] = number%P4;
pos[4] = number%P5;
if (tableOne [pos[0]] == number or tableTwo [pos[1]] == number
or tableThree[pos[2]] == number or tableFour[pos[3]] == number
or tableFive [pos[4]] == number)
return true;
else
return false;
}
int main(){
int tests;
cin >> tests;
int operation;
long long number;
for (; tests; tests--){
cin >> operation >> number;
int pos[5];
pos[0] = number%P1;
pos[1] = number%P2;
pos[2] = number%P3;
pos[3] = number%P4;
pos[4] = number%P5;
if (operation == 1){
if (isIn(number) == false){
tableOne [pos[0]] = number;
tableTwo [pos[1]] = number;
tableThree[pos[2]] = number;
tableFour [pos[3]] = number;
tableFive [pos[4]] = number;
}
}
if (operation == 2){
if (tableOne [pos[0]] == number)
tableOne [pos[0]] = 0;
if (tableTwo [pos[1]] == number)
tableTwo [pos[1]] = 0;
if (tableThree[pos[2]] == number)
tableThree[pos[2]] = 0;
if (tableFour [pos[3]] == number)
tableFour [pos[3]] = 0;
if (tableFive [pos[4]] == number)
tableFive [pos[4]] = 0;
}
if (operation == 3){
if (isIn(number))
cout << "1\n";
else
cout << "0\n";
}
}
}