# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1036202 | 2024-07-27T05:07:20 Z | vjudge1 | Naboj (COCI22_naboj) | C++17 | 442 ms | 20164 KB |
#include<bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> G[n + 1]; for(int i = 0; i < m; i++) { int u, v; cin >> u >> v; G[u].push_back(v); } vector<int> topo, zero; int in[n + 1] = {}; for(int i = 1; i <= n; i ++) for(int j : G[i]) in[j]++; for(int i = 1; i <= n; i ++) if(in[i] == 0) zero.push_back(i); while(zero.size()) { int u = zero.back(); topo.push_back(u); zero.pop_back(); for(int v : G[u]) { in[v]--; if(in[v] == 0) zero.push_back(v); } } if(topo.size() != n) cout << -1 << endl; else { cout << n << endl; for(int i : topo) cout << i << ' ' << 0 << endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 436 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 332 ms | 15336 KB | Output is correct |
2 | Correct | 284 ms | 15464 KB | Output is correct |
3 | Correct | 159 ms | 8272 KB | Output is correct |
4 | Correct | 281 ms | 15372 KB | Output is correct |
5 | Correct | 314 ms | 15328 KB | Output is correct |
6 | Correct | 290 ms | 15308 KB | Output is correct |
7 | Correct | 338 ms | 15428 KB | Output is correct |
8 | Correct | 224 ms | 12104 KB | Output is correct |
9 | Correct | 283 ms | 15432 KB | Output is correct |
10 | Correct | 316 ms | 15484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 436 KB | Output is correct |
15 | Correct | 332 ms | 15336 KB | Output is correct |
16 | Correct | 284 ms | 15464 KB | Output is correct |
17 | Correct | 159 ms | 8272 KB | Output is correct |
18 | Correct | 281 ms | 15372 KB | Output is correct |
19 | Correct | 314 ms | 15328 KB | Output is correct |
20 | Correct | 290 ms | 15308 KB | Output is correct |
21 | Correct | 338 ms | 15428 KB | Output is correct |
22 | Correct | 224 ms | 12104 KB | Output is correct |
23 | Correct | 283 ms | 15432 KB | Output is correct |
24 | Correct | 316 ms | 15484 KB | Output is correct |
25 | Correct | 152 ms | 13512 KB | Output is correct |
26 | Correct | 127 ms | 15436 KB | Output is correct |
27 | Correct | 148 ms | 16464 KB | Output is correct |
28 | Correct | 184 ms | 18004 KB | Output is correct |
29 | Correct | 104 ms | 14920 KB | Output is correct |
30 | Correct | 202 ms | 17764 KB | Output is correct |
31 | Correct | 28 ms | 2640 KB | Output is correct |
32 | Correct | 294 ms | 14800 KB | Output is correct |
33 | Correct | 392 ms | 19284 KB | Output is correct |
34 | Correct | 305 ms | 15300 KB | Output is correct |
35 | Correct | 409 ms | 19448 KB | Output is correct |
36 | Correct | 302 ms | 14528 KB | Output is correct |
37 | Correct | 368 ms | 18416 KB | Output is correct |
38 | Correct | 341 ms | 17088 KB | Output is correct |
39 | Correct | 398 ms | 19148 KB | Output is correct |
40 | Correct | 442 ms | 17860 KB | Output is correct |
41 | Correct | 330 ms | 17868 KB | Output is correct |
42 | Correct | 389 ms | 19908 KB | Output is correct |
43 | Correct | 379 ms | 15816 KB | Output is correct |
44 | Correct | 402 ms | 20164 KB | Output is correct |
45 | Correct | 298 ms | 15048 KB | Output is correct |
46 | Correct | 394 ms | 17848 KB | Output is correct |