# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
852284 | 2023-09-21T14:16:20 Z | Trisanu_Das | Naboj (COCI22_naboj) | C++17 | 248 ms | 20268 KB |
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<int> deg(n + 1), adj[n + 1], topo; int a, b; while(m--){ cin >> a >> b; deg[b]++; adj[a].push_back(b); } queue<int> q; for(int i = 1; i <= n; i++) if(deg[i] == 0) q.push(i); while(!q.empty()){ int u = q.front(); q.pop(); topo.push_back(u); for(auto v : adj[u]){ deg[v]--; if(deg[v] == 0) q.push(v); } } if(topo.size() != n) cout << -1; else { cout << n << '\n'; for(auto x : topo) cout << x << ' ' << 0 << '\n'; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 85 ms | 12804 KB | Output is correct |
2 | Correct | 84 ms | 15372 KB | Output is correct |
3 | Correct | 33 ms | 8144 KB | Output is correct |
4 | Correct | 74 ms | 15304 KB | Output is correct |
5 | Correct | 101 ms | 15304 KB | Output is correct |
6 | Correct | 95 ms | 15304 KB | Output is correct |
7 | Correct | 85 ms | 15328 KB | Output is correct |
8 | Correct | 71 ms | 12036 KB | Output is correct |
9 | Correct | 89 ms | 15308 KB | Output is correct |
10 | Correct | 104 ms | 15648 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 85 ms | 12804 KB | Output is correct |
16 | Correct | 84 ms | 15372 KB | Output is correct |
17 | Correct | 33 ms | 8144 KB | Output is correct |
18 | Correct | 74 ms | 15304 KB | Output is correct |
19 | Correct | 101 ms | 15304 KB | Output is correct |
20 | Correct | 95 ms | 15304 KB | Output is correct |
21 | Correct | 85 ms | 15328 KB | Output is correct |
22 | Correct | 71 ms | 12036 KB | Output is correct |
23 | Correct | 89 ms | 15308 KB | Output is correct |
24 | Correct | 104 ms | 15648 KB | Output is correct |
25 | Correct | 98 ms | 13648 KB | Output is correct |
26 | Correct | 107 ms | 15456 KB | Output is correct |
27 | Correct | 91 ms | 16584 KB | Output is correct |
28 | Correct | 152 ms | 18000 KB | Output is correct |
29 | Correct | 79 ms | 15060 KB | Output is correct |
30 | Correct | 125 ms | 18164 KB | Output is correct |
31 | Correct | 14 ms | 2688 KB | Output is correct |
32 | Correct | 79 ms | 14788 KB | Output is correct |
33 | Correct | 128 ms | 19388 KB | Output is correct |
34 | Correct | 111 ms | 15352 KB | Output is correct |
35 | Correct | 150 ms | 19520 KB | Output is correct |
36 | Correct | 76 ms | 14604 KB | Output is correct |
37 | Correct | 125 ms | 18436 KB | Output is correct |
38 | Correct | 100 ms | 17156 KB | Output is correct |
39 | Correct | 131 ms | 19188 KB | Output is correct |
40 | Correct | 119 ms | 17924 KB | Output is correct |
41 | Correct | 151 ms | 17912 KB | Output is correct |
42 | Correct | 192 ms | 19912 KB | Output is correct |
43 | Correct | 107 ms | 15860 KB | Output is correct |
44 | Correct | 248 ms | 20268 KB | Output is correct |
45 | Correct | 78 ms | 15124 KB | Output is correct |
46 | Correct | 114 ms | 17940 KB | Output is correct |