Cod sursa(job #1757902)

Utilizator Burbon13Burbon13 Burbon13 Data 16 septembrie 2016 02:00:43
Problema Componente biconexe Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.85 kb
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int mod = 666013;

int n;
vector <int> g[mod];

int main()
{
    freopen("hashuri.in", "r", stdin);
    freopen("hashuri.out", "w", stdout);

    int nr, val, cmd;

    scanf("%d", &nr);
    for(int i = 1; i <= nr; ++i)
    {
        scanf("%d %d", &cmd, &val);

        if(cmd == 1)
            g[val % mod].push_back(val);
        else if(cmd == 2)
        {
            vector <int>::iterator it = find(g[val%mod].begin(),g[val%mod].end(),val);

            if(it != g[val%mod].end())
                g[val%mod].erase(it);
        }
        else
        {
            vector <int>::iterator it = find(g[val%mod].begin(),g[val%mod].end(),val);

            printf("%d\n", it != g[val%mod].end() ? 1 : 0);
        }

    }

    return 0;
}