Cod sursa(job #2023735)

Utilizator Dragne.Andrei11Dragne Andrei Dragne.Andrei11 Data 19 septembrie 2017 13:52:36
Problema Hashuri Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.8 kb
#include <cstdio>
#define nmax 100000

using namespace std;

int resturi[nmax+1];
int cat[20001];
int main()
{
    freopen("hashuri.in", "r", stdin);
    freopen("hashuri.out", "w", stdout);
    int n;

    scanf("%d", &n);
    for(int i=1;i<=n;i++)
    {
        int nr, op;
        scanf("%d%d", &op, &nr);
        if(op==1)
        {
            resturi[nr%nmax]++;
            cat[nr/nmax]++;
        }
        else if(op==2)
        {
            if(resturi[nr%nmax]&&cat[nr/nmax])
            {
                resturi[nr%nmax]--;
                cat[nr/nmax]--;
            }
        }else if(op==3)
        {
            if(resturi[nr%nmax]&&cat[nr/nmax])
                printf("1\n");
            else
                printf("0\n");
        }
    }

    return 0;
}