52702023-04-25 06:22:59anonDinókcpp17Wrong answer 0/100519ms91992 KiB
#include <vector>
#include <queue>
#include <unordered_set>
#include <iostream>

using ll = long long;
using namespace std;

int main()
{
    ll i, j, c, e, t, a, b, N, M;

    cin >> N >> M;

    vector<vector<ll>> ss(M);

    for(i = 0; i < M; i++)
    {
        cin >> t >> a >> b;
        ss[i] = vector<ll> { t, a, b };
    }

    vector<unordered_set<ll>> g(2 * N + 1);
    vector<ll> ine(2 * N + 1, 0);

    for(i = 0; i < M; i++)
    {
        switch(ss[i][0])
        {
            case 1:
                g[ss[i][1]].insert(ss[i][2] + N);
                ine[ss[i][2] + N]++;

                g[ss[i][2]].insert(ss[i][1] + N);
                ine[ss[i][1] + N]++;
            break;
            case 2:
                g[ss[i][1] + N].insert(ss[i][2]);
                ine[ss[i][2]]++;
            break;
            default:
            break;
        }
    }

    for(i = 1; i <= N; i++)
    {
        g[i].insert(i + N);
        ine[i + N]++;
    }

    c = 1;
    vector<ll> ans(2 * N + 1, 0);

    queue<ll> q;

    for(i = 1; i <= N; i++)
    {
        if(!ine[i])
            q.push(i);
    }

    while(q.size())
    {
        e = q.front();
        q.pop();

        ans[e] = c++;

        for(auto x : g[e])
        {
            if(!--ine[x])
                q.push(x);
        }
    }

    for(i = 1; i <= 2 * N; i++)
    {
        if(!ans[i])
        {
            cout << "NEM" << endl;
            return 0;
        }
    }

    cout << "IGEN" << endl;

    for(i = 1; i <= N; i++)
        cout << ans[i] << ' ' << ans[i + N] << endl;

    return 0;
}

SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1808 KiB
2Accepted3ms2060 KiB
3Accepted10ms6324 KiB
subtask20/5
4Wrong answer277ms83448 KiB
5Accepted354ms72176 KiB
6Accepted280ms66372 KiB
subtask30/15
7Accepted3ms2724 KiB
8Accepted3ms2852 KiB
9Accepted3ms2936 KiB
10Wrong answer3ms3064 KiB
11Wrong answer3ms3144 KiB
12Accepted3ms3176 KiB
subtask40/10
13Wrong answer3ms3264 KiB
14Wrong answer3ms3252 KiB
15Accepted3ms3252 KiB
16Accepted3ms3384 KiB
17Wrong answer3ms3600 KiB
subtask50/35
18Accepted3ms3728 KiB
19Wrong answer3ms4380 KiB
20Wrong answer223ms91580 KiB
21Wrong answer228ms91992 KiB
22Accepted3ms3924 KiB
23Accepted4ms4704 KiB
24Accepted223ms91792 KiB
subtask60/35
25Wrong answer275ms87984 KiB
26Wrong answer230ms87884 KiB
27Wrong answer279ms87972 KiB
28Wrong answer228ms88096 KiB
29Accepted224ms90424 KiB
30Accepted409ms89440 KiB
31Time limit exceeded519ms88660 KiB
32Accepted231ms90488 KiB
33Accepted206ms91920 KiB
34Accepted432ms89320 KiB
35Accepted316ms86576 KiB