Cod sursa(job #1523348)

Utilizator theodor.moroianuTheodor Moroianu theodor.moroianu Data 12 noiembrie 2015 17:13:19
Problema Hashuri Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 1.11 kb
#include <fstream>
using namespace std;
const int p1 = 666013, p2 = 666019, p3 = 666023, p4 = 666025, p5 = 777777;
short v[p1], u[p2], k[p3], l[p4], m[p5];

int main(){

    ifstream in("hashuri.in");
    int n, q;
    ofstream out("hashuri.out");
    char c;
    in >> n;
    while (n--){
        in >> c >> q;
        switch(c){
            case '1':
                v[q % p1]++;
                u[q % p2]++;
                k[q % p3]++;
                l[q % p4]++;
                m[q % p5]++;
                break;
            case '2':
                if (v[q % p1] && u[q % p2] && k[q % p3] && l[q % p4] && m[q % p5]){
                    v[q % p1]--;
                    u[q % p2]--;
                    k[q % p3]--;
                    l[q % p4]--;
                    m[q % p5]--;
                }
                break;
            case '3':
                if (v[q % p1] && u[q % p2] && k[q % p3] && l[q % p4] && m[q % p5]){
                    out << "1\n";
                }
                else
                    out << "0\n";
                break;
        }
    }
    in.close();
    out.close();
    return 0;
}