Cod sursa(job #2405114)

Utilizator AkrielAkriel Akriel Data 13 aprilie 2019 22:39:20
Problema Hashuri Scor 60
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.12 kb
#include <fstream>

#define debug(x) cerr << #x": " << x << "\n"

using namespace std;

const int P1 = 1023135;
const int P2 = 1000823;
const int P3 = 1003527;

long long tableOne[P1];
long long tableTwo[P2];
long long tableThree[P3];

ifstream cin("hashuri.in");
ofstream cout("hashuri.out");

int main(){
    int tests;
    cin >> tests;

    int operation;
    long long number;
    for (; tests; tests--){
        cin >> operation >> number;

        int pos[3];
        pos[0] = number%P1;
        pos[1] = number%P2;
        pos[2] = number%P3;


        if (operation == 1){
            tableOne  [pos[0]] = number;
            tableTwo  [pos[1]] = number;
            tableThree[pos[2]] = number;
        }

        if (operation == 2){
            tableOne  [pos[0]] = 0;
            tableTwo  [pos[1]] = 0;
            tableThree[pos[2]] = 0;
        }

        if (operation == 3){
            if (tableOne[pos[0]] == number or tableTwo[pos[1]] == number or tableThree[pos[2]] == number)
                cout << "1\n";
            else
                cout << "0\n";
        }
    }
}