5212 | 2023-04-22 18:30:48 | ZsofiaKeresztely | Dinók | cpp14 | Accepted 100/100 | 165ms | 29736 KiB |
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<int> ind;
vector<int> op;
int n, last = 1;
void bfs(){
queue<int> q;
for (int i=1; i<=n; i++){
if (!ind[i]){
q.push(i);
}
}
while (!q.empty()){
int v = q.front();
q.pop();
op[v] = last;
last++;
for (int x : g[v]){
ind[x]--;
if (!ind[x]) q.push(x);
}
}
}
int main()
{
int m;
cin >> n >> m;
g.resize(2*n+1);
ind.assign(2*n+1, 0);
op.assign(2*n+1, 0);
while (m--){
int t, a, b;
cin >> t >> a >> b;
if (t == 2){
g[a + n].push_back(b);
ind[b]++;
}
else{
g[b].push_back(a + n);
g[a].push_back(b + n);
ind[a+n]++;
ind[b+n]++;
}
}
for (int i=1; i<=n; i++){
g[i].push_back(i + n);
ind[i+n]++;
}
bfs();
for (int i=1; i<=2*n; i++){
if (!op[i]){
cout << "NEM";
return 0;
}
}
cout << "IGEN";
for (int i=1; i<=n; i++){
cout << "\n" << op[i] << " " << op[i + n];
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1808 KiB | ||||
2 | Accepted | 3ms | 2060 KiB | ||||
3 | Accepted | 8ms | 3184 KiB | ||||
subtask2 | 5/5 | ||||||
4 | Accepted | 157ms | 23892 KiB | ||||
5 | Accepted | 96ms | 24652 KiB | ||||
6 | Accepted | 74ms | 25080 KiB | ||||
subtask3 | 15/15 | ||||||
7 | Accepted | 3ms | 5728 KiB | ||||
8 | Accepted | 3ms | 5624 KiB | ||||
9 | Accepted | 2ms | 5716 KiB | ||||
10 | Accepted | 2ms | 5744 KiB | ||||
11 | Accepted | 3ms | 5720 KiB | ||||
12 | Accepted | 3ms | 5704 KiB | ||||
subtask4 | 10/10 | ||||||
13 | Accepted | 3ms | 5792 KiB | ||||
14 | Accepted | 3ms | 5924 KiB | ||||
15 | Accepted | 3ms | 6164 KiB | ||||
16 | Accepted | 3ms | 6260 KiB | ||||
17 | Accepted | 2ms | 6376 KiB | ||||
subtask5 | 35/35 | ||||||
18 | Accepted | 3ms | 6300 KiB | ||||
19 | Accepted | 3ms | 6444 KiB | ||||
20 | Accepted | 148ms | 29536 KiB | ||||
21 | Accepted | 145ms | 29620 KiB | ||||
22 | Accepted | 3ms | 6600 KiB | ||||
23 | Accepted | 3ms | 6676 KiB | ||||
24 | Accepted | 122ms | 29736 KiB | ||||
subtask6 | 35/35 | ||||||
25 | Accepted | 152ms | 27604 KiB | ||||
26 | Accepted | 150ms | 27612 KiB | ||||
27 | Accepted | 164ms | 27696 KiB | ||||
28 | Accepted | 164ms | 27700 KiB | ||||
29 | Accepted | 133ms | 28520 KiB | ||||
30 | Accepted | 157ms | 28280 KiB | ||||
31 | Accepted | 165ms | 27996 KiB | ||||
32 | Accepted | 134ms | 28408 KiB | ||||
33 | Accepted | 129ms | 29580 KiB | ||||
34 | Accepted | 158ms | 28244 KiB | ||||
35 | Accepted | 128ms | 27340 KiB |