Pagini recente » Cod sursa (job #1441965) | Cod sursa (job #324346) | Cod sursa (job #2690058) | Cod sursa (job #3296275) | Cod sursa (job #2405135)
#include <fstream>
#define debug(x) cerr << #x": " << x << "\n"
using namespace std;
const int P1 = 1662803;
const int P2 = 1678321;
const int P3 = 1235711;
const int P4 = 1831381;
long long tableOne [P1];
long long tableTwo [P2];
long long tableThree[P3];
long long tableFour [P4];
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
bool isIn(int number){
int pos[4];
pos[0] = number%P1;
pos[1] = number%P2;
pos[2] = number%P3;
pos[3] = number%P4;
if (tableOne[pos[0]] == number or tableTwo[pos[1]] == number
or tableThree[pos[2]] == number or tableFour[pos[3]] == 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[4];
pos[0] = number%P1;
pos[1] = number%P2;
pos[2] = number%P3;
pos[3] = number%P4;
if (operation == 1){
if (isIn(number) == false){
tableOne [pos[0]] = number;
tableTwo [pos[1]] = number;
tableThree[pos[2]] = number;
tableFour [pos[3]] = 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 (operation == 3){
if (isIn(number))
cout << "1\n";
else
cout << "0\n";
}
}
}