# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
718504 | 2023-04-04T09:05:30 Z | Augustyn | Naboj (COCI22_naboj) | C++17 | 296 ms | 21328 KB |
#include<iostream> #include<vector> using namespace std; int n,m; vector<int>*pol; bool *juzodw,*terodw; int *stp_wch,*odp,iter; bool dfs(int ter) { juzodw[ter]=1; terodw[ter]=1; for(auto i:pol[ter]) { if(terodw[i]==1) return 1; if(juzodw[i]==0) if(dfs(i)) return 1; } terodw[ter]=0; odp[++iter]=ter; return 0; } int main() { scanf("%d%d",&n,&m); pol=new vector<int>[n+1]; juzodw=new bool[n+1]; terodw=new bool[n+1]; odp=new int[n+1]; stp_wch=new int[n+1]; while(m) { --m; int a,b; scanf("%d%d",&a,&b); pol[b].push_back(a); stp_wch[a]++; } for(int i=1;i<=n;++i) if(stp_wch[i]==0) if(dfs(i)) { printf("-1"); return 0; } if(iter!=n) { printf("-1"); return 0; } printf("%d\n",n); for(int i=1;i<=n;++i) printf("%d 0\n",odp[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 300 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 304 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 114 ms | 15424 KB | Output is correct |
2 | Correct | 137 ms | 15260 KB | Output is correct |
3 | Correct | 54 ms | 8016 KB | Output is correct |
4 | Correct | 130 ms | 15280 KB | Output is correct |
5 | Correct | 127 ms | 15256 KB | Output is correct |
6 | Correct | 120 ms | 15324 KB | Output is correct |
7 | Correct | 114 ms | 15352 KB | Output is correct |
8 | Correct | 111 ms | 11884 KB | Output is correct |
9 | Correct | 115 ms | 15320 KB | Output is correct |
10 | Correct | 107 ms | 15364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 300 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 304 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 114 ms | 15424 KB | Output is correct |
16 | Correct | 137 ms | 15260 KB | Output is correct |
17 | Correct | 54 ms | 8016 KB | Output is correct |
18 | Correct | 130 ms | 15280 KB | Output is correct |
19 | Correct | 127 ms | 15256 KB | Output is correct |
20 | Correct | 120 ms | 15324 KB | Output is correct |
21 | Correct | 114 ms | 15352 KB | Output is correct |
22 | Correct | 111 ms | 11884 KB | Output is correct |
23 | Correct | 115 ms | 15320 KB | Output is correct |
24 | Correct | 107 ms | 15364 KB | Output is correct |
25 | Correct | 154 ms | 13648 KB | Output is correct |
26 | Correct | 128 ms | 14968 KB | Output is correct |
27 | Correct | 162 ms | 16240 KB | Output is correct |
28 | Correct | 223 ms | 18036 KB | Output is correct |
29 | Correct | 93 ms | 13900 KB | Output is correct |
30 | Correct | 195 ms | 17952 KB | Output is correct |
31 | Correct | 21 ms | 2584 KB | Output is correct |
32 | Correct | 127 ms | 17688 KB | Output is correct |
33 | Correct | 231 ms | 20720 KB | Output is correct |
34 | Correct | 195 ms | 17916 KB | Output is correct |
35 | Correct | 296 ms | 20816 KB | Output is correct |
36 | Correct | 109 ms | 17624 KB | Output is correct |
37 | Correct | 210 ms | 20112 KB | Output is correct |
38 | Correct | 162 ms | 19276 KB | Output is correct |
39 | Correct | 235 ms | 20612 KB | Output is correct |
40 | Correct | 179 ms | 19716 KB | Output is correct |
41 | Correct | 193 ms | 19660 KB | Output is correct |
42 | Correct | 248 ms | 21328 KB | Output is correct |
43 | Correct | 139 ms | 18380 KB | Output is correct |
44 | Correct | 204 ms | 21324 KB | Output is correct |
45 | Correct | 130 ms | 17900 KB | Output is correct |
46 | Correct | 206 ms | 19712 KB | Output is correct |