# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782221 | 2023-07-13T16:31:18 Z | devariaota | Naboj (COCI22_naboj) | C++17 | 245 ms | 17640 KB |
#include <bits/stdc++.h> #define LL long long using namespace std; int main() { LL n,m; scanf("%lld %lld",&n,&m); vector<LL>adj[n+5]; LL degree[n+5]; memset(degree,0,sizeof(degree)); for(LL a=1;a<=m;a++) { LL x,y; scanf("%lld %lld",&x,&y); adj[x].push_back(y); degree[y]++; } queue<LL>q; vector<LL>v; for(LL a=1;a<=n;a++) { if(!degree[a]) { q.push(a); v.push_back(a); } } while(!q.empty()) { LL x=q.front(); q.pop(); for(LL a:adj[x]) { degree[a]--; if(!degree[a]) { q.push(a); v.push_back(a); } } } if(v.size()!=n)printf("-1\n"); else{ printf("%lld\n",v.size()); for(LL a:v) { printf("%lld 0\n",a); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 81 ms | 14740 KB | Output is correct |
2 | Correct | 84 ms | 14716 KB | Output is correct |
3 | Correct | 37 ms | 7924 KB | Output is correct |
4 | Correct | 122 ms | 14772 KB | Output is correct |
5 | Correct | 89 ms | 14736 KB | Output is correct |
6 | Correct | 81 ms | 14752 KB | Output is correct |
7 | Correct | 77 ms | 14832 KB | Output is correct |
8 | Correct | 54 ms | 11620 KB | Output is correct |
9 | Correct | 92 ms | 14780 KB | Output is correct |
10 | Correct | 76 ms | 14716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 81 ms | 14740 KB | Output is correct |
16 | Correct | 84 ms | 14716 KB | Output is correct |
17 | Correct | 37 ms | 7924 KB | Output is correct |
18 | Correct | 122 ms | 14772 KB | Output is correct |
19 | Correct | 89 ms | 14736 KB | Output is correct |
20 | Correct | 81 ms | 14752 KB | Output is correct |
21 | Correct | 77 ms | 14832 KB | Output is correct |
22 | Correct | 54 ms | 11620 KB | Output is correct |
23 | Correct | 92 ms | 14780 KB | Output is correct |
24 | Correct | 76 ms | 14716 KB | Output is correct |
25 | Correct | 108 ms | 11160 KB | Output is correct |
26 | Correct | 91 ms | 13496 KB | Output is correct |
27 | Correct | 118 ms | 13780 KB | Output is correct |
28 | Correct | 185 ms | 14956 KB | Output is correct |
29 | Correct | 125 ms | 14084 KB | Output is correct |
30 | Correct | 185 ms | 14756 KB | Output is correct |
31 | Correct | 18 ms | 2228 KB | Output is correct |
32 | Correct | 117 ms | 14132 KB | Output is correct |
33 | Correct | 148 ms | 17216 KB | Output is correct |
34 | Correct | 101 ms | 14312 KB | Output is correct |
35 | Correct | 166 ms | 17152 KB | Output is correct |
36 | Correct | 120 ms | 14032 KB | Output is correct |
37 | Correct | 200 ms | 16564 KB | Output is correct |
38 | Correct | 182 ms | 15664 KB | Output is correct |
39 | Correct | 194 ms | 17064 KB | Output is correct |
40 | Correct | 137 ms | 16176 KB | Output is correct |
41 | Correct | 140 ms | 16132 KB | Output is correct |
42 | Correct | 173 ms | 17616 KB | Output is correct |
43 | Correct | 120 ms | 14608 KB | Output is correct |
44 | Correct | 245 ms | 17640 KB | Output is correct |
45 | Correct | 115 ms | 14280 KB | Output is correct |
46 | Correct | 137 ms | 16096 KB | Output is correct |