13852022-08-30 13:33:57mraronDinókcpp17Elfogadva 100/100103ms33448 KiB
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair
#define ins insert

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

using ll = long long;
using ull = unsigned long long ;
using ld = long double ;
using str = string;
using ordered_set=tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
    T val=0;
    char c;
    
    bool neg=false;
    while((c=gc()) && !(c>='0' && c<='9')) {
        neg|=c=='-';
    }

    do {
        val=(val*10)+c-'0';
    } while((c=gc()) && (c>='0' && c<='9'));

    return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

vector<int> adj[200001];
int indeg[200001];
void add_edge(int x, int y) {
    adj[x].push_back(y);
    indeg[y]++;
}

vector<int> ord;
int st[200001];
int pos[200001];
void dfs(int x) {
    if(indeg[x]==0) {
        st[x]=1;
        ord.pb(x);
        pos[x]=sz(ord)-1;
        for(auto i:adj[x]) {
            indeg[i]--;
            if(indeg[i]==0) {
                dfs(i);
            }
        }
    }
}

int main() {
    IO;
    int n,m;
    cin>>n>>m;
    vector<array<int,3>> t(m);
    for(int i=0;i<n;++i) {
        add_edge(2*i, 2*i+1);
    }
    for(int i=0;i<m;++i) {
        cin>>t[i][0]>>t[i][1]>>t[i][2];
        
        t[i][1]--;
        t[i][2]--;
        
        if(t[i][0]==1) {
            add_edge(t[i][1]*2, t[i][2]*2+1);
            add_edge(t[i][2]*2, t[i][1]*2+1);
        }else {
            add_edge(t[i][1]*2+1, t[i][2]*2);
        }
    }

    for(int i=0;i<2*n;++i) {
        if(!st[i]) dfs(i);
    }

    if(ord.size()==2*n) {
        cout<<"IGEN\n";
        for(int i=0;i<n;++i) {
            cout<<pos[2*i]+1<<" "<<pos[2*i+1]+1<<"\n";
        }
    }else {
        cout<<"NEM\n";
    }

    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
subtask10/0
1Elfogadva6ms11260 KiB
2Elfogadva6ms11512 KiB
3Elfogadva8ms12728 KiB
subtask25/5
4Elfogadva90ms28384 KiB
5Elfogadva71ms26376 KiB
6Elfogadva52ms25792 KiB
subtask315/15
7Elfogadva4ms12540 KiB
8Elfogadva6ms12756 KiB
9Elfogadva6ms12832 KiB
10Elfogadva6ms13076 KiB
11Elfogadva6ms13308 KiB
12Elfogadva6ms13388 KiB
subtask410/10
13Elfogadva6ms13212 KiB
14Elfogadva6ms13212 KiB
15Elfogadva6ms13284 KiB
16Elfogadva4ms13532 KiB
17Elfogadva4ms13612 KiB
subtask535/35
18Elfogadva4ms13724 KiB
19Elfogadva4ms13904 KiB
20Elfogadva87ms33008 KiB
21Elfogadva86ms32892 KiB
22Elfogadva4ms13680 KiB
23Elfogadva6ms14136 KiB
24Elfogadva79ms33448 KiB
subtask635/35
25Elfogadva90ms31352 KiB
26Elfogadva97ms31468 KiB
27Elfogadva90ms31420 KiB
28Elfogadva101ms31468 KiB
29Elfogadva75ms32396 KiB
30Elfogadva103ms32048 KiB
31Elfogadva103ms31640 KiB
32Elfogadva75ms32388 KiB
33Elfogadva71ms33236 KiB
34Elfogadva90ms31648 KiB
35Elfogadva79ms31216 KiB