# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1090107 | 2024-09-17T17:56:24 Z | Onur_Ilgaz | Naboj (COCI22_naboj) | C++17 | 142 ms | 25000 KB |
#include <bits/stdc++.h> #define fast cin.tie(0)->sync_with_stdio(0); #define int long long #define inf ((int)1e18) using namespace std; int32_t main(){ fast int n, m; cin >> n >> m; vector <vector <int> > adj(n + 1); vector <int> to(n + 1); for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; adj[b].push_back(a); to[a]++; } vector <int> ans, zeros; for(int i = 1; i <= n; i++) { if(!to[i]) { zeros.push_back(i); } } while(!zeros.empty()) { int node = zeros.back(); ans.push_back(node); // cout << node << "\n"; zeros.pop_back(); for(auto it:adj[node]) { to[it]--; if(to[it] == 0) zeros.push_back(it); } } if(ans.size() != n) { cout << -1 << "\n"; return 0; } cout << n << "\n"; for(auto it:ans) { cout << it << " " << 1 << "\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 344 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 | 344 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 65 ms | 17476 KB | Output is correct |
2 | Correct | 64 ms | 17476 KB | Output is correct |
3 | Correct | 36 ms | 9340 KB | Output is correct |
4 | Correct | 74 ms | 17588 KB | Output is correct |
5 | Correct | 66 ms | 17472 KB | Output is correct |
6 | Correct | 66 ms | 17476 KB | Output is correct |
7 | Correct | 72 ms | 17472 KB | Output is correct |
8 | Correct | 50 ms | 13640 KB | Output is correct |
9 | Correct | 66 ms | 17476 KB | Output is correct |
10 | Correct | 65 ms | 17484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 344 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 | 344 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 65 ms | 17476 KB | Output is correct |
16 | Correct | 64 ms | 17476 KB | Output is correct |
17 | Correct | 36 ms | 9340 KB | Output is correct |
18 | Correct | 74 ms | 17588 KB | Output is correct |
19 | Correct | 66 ms | 17472 KB | Output is correct |
20 | Correct | 66 ms | 17476 KB | Output is correct |
21 | Correct | 72 ms | 17472 KB | Output is correct |
22 | Correct | 50 ms | 13640 KB | Output is correct |
23 | Correct | 66 ms | 17476 KB | Output is correct |
24 | Correct | 65 ms | 17484 KB | Output is correct |
25 | Correct | 73 ms | 16208 KB | Output is correct |
26 | Correct | 77 ms | 17556 KB | Output is correct |
27 | Correct | 78 ms | 18764 KB | Output is correct |
28 | Correct | 95 ms | 21200 KB | Output is correct |
29 | Correct | 59 ms | 17484 KB | Output is correct |
30 | Correct | 99 ms | 20976 KB | Output is correct |
31 | Correct | 18 ms | 3160 KB | Output is correct |
32 | Correct | 75 ms | 19784 KB | Output is correct |
33 | Correct | 131 ms | 23876 KB | Output is correct |
34 | Correct | 93 ms | 20024 KB | Output is correct |
35 | Correct | 122 ms | 24128 KB | Output is correct |
36 | Correct | 78 ms | 19776 KB | Output is correct |
37 | Correct | 107 ms | 22968 KB | Output is correct |
38 | Correct | 117 ms | 21572 KB | Output is correct |
39 | Correct | 142 ms | 23872 KB | Output is correct |
40 | Correct | 134 ms | 22340 KB | Output is correct |
41 | Correct | 102 ms | 22336 KB | Output is correct |
42 | Correct | 135 ms | 24648 KB | Output is correct |
43 | Correct | 78 ms | 20544 KB | Output is correct |
44 | Correct | 127 ms | 25000 KB | Output is correct |
45 | Correct | 74 ms | 20044 KB | Output is correct |
46 | Correct | 97 ms | 22352 KB | Output is correct |