Cod sursa(job #2405116)

Utilizator AkrielAkriel Akriel Data 13 aprilie 2019 22:41:44
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.31 kb
#include <fstream>

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

using namespace std;

const int P1 = 1023135;
const int P2 = 1500823;
const int P3 = 2213527;
const int P4 = 512353;

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

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;
        pos[3] = number%P4;


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

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

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