5211 | 2023-04-22 18:24:11 | ZsofiaKeresztely | Dinók | cpp14 | Runtime error 35/100 | 181ms | 27068 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]++;
}
int ii=0;
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 | Runtime error | 2ms | 1436 KiB | ||||
2 | Runtime error | 2ms | 1684 KiB | ||||
3 | Runtime error | 2ms | 1844 KiB | ||||
subtask2 | 0/5 | ||||||
4 | Runtime error | 2ms | 1996 KiB | ||||
5 | Runtime error | 2ms | 2004 KiB | ||||
6 | Runtime error | 2ms | 2148 KiB | ||||
subtask3 | 0/15 | ||||||
7 | Runtime error | 2ms | 2284 KiB | ||||
8 | Runtime error | 2ms | 2344 KiB | ||||
9 | Runtime error | 2ms | 2432 KiB | ||||
10 | Runtime error | 2ms | 2624 KiB | ||||
11 | Runtime error | 2ms | 2784 KiB | ||||
12 | Runtime error | 2ms | 2880 KiB | ||||
subtask4 | 0/10 | ||||||
13 | Runtime error | 2ms | 3028 KiB | ||||
14 | Runtime error | 2ms | 3028 KiB | ||||
15 | Runtime error | 2ms | 3100 KiB | ||||
16 | Runtime error | 2ms | 3024 KiB | ||||
17 | Runtime error | 2ms | 2996 KiB | ||||
subtask5 | 0/35 | ||||||
18 | Runtime error | 2ms | 3036 KiB | ||||
19 | Runtime error | 3ms | 3044 KiB | ||||
20 | Accepted | 164ms | 26684 KiB | ||||
21 | Accepted | 153ms | 26780 KiB | ||||
22 | Accepted | 3ms | 3724 KiB | ||||
23 | Accepted | 4ms | 4100 KiB | ||||
24 | Accepted | 119ms | 26956 KiB | ||||
subtask6 | 35/35 | ||||||
25 | Accepted | 152ms | 24988 KiB | ||||
26 | Accepted | 151ms | 24984 KiB | ||||
27 | Accepted | 159ms | 24912 KiB | ||||
28 | Accepted | 153ms | 25052 KiB | ||||
29 | Accepted | 128ms | 25632 KiB | ||||
30 | Accepted | 152ms | 25796 KiB | ||||
31 | Accepted | 151ms | 25500 KiB | ||||
32 | Accepted | 144ms | 26168 KiB | ||||
33 | Accepted | 140ms | 27068 KiB | ||||
34 | Accepted | 181ms | 25856 KiB | ||||
35 | Accepted | 137ms | 24952 KiB |