# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
718516 | 2023-04-04T09:15:21 Z | Augustyn | Naboj (COCI22_naboj) | C++17 | 286 ms | 15212 KB |
#include<iostream> #include<vector> using namespace std; int n,m; vector<int>*pol; bool *juzodw,*terodw; int *stp_wch,*odp,it; bool dfs(int t) { juzodw[t]=1; terodw[t]=1; for(int i:pol[t]) { if(terodw[i]==1) return 1; if(juzodw[i]==0) if(dfs(i)) return 1; } terodw[t]=0; odp[++it]=t; 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(it!=n) { printf("-1"); return 0; } printf("%d\n",n); for(int i=1;i<=n;++i) printf("%d 0\n",odp[i]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 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 | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 131 ms | 12808 KB | Output is correct |
2 | Correct | 128 ms | 12748 KB | Output is correct |
3 | Correct | 74 ms | 6860 KB | Output is correct |
4 | Correct | 96 ms | 12860 KB | Output is correct |
5 | Correct | 103 ms | 12784 KB | Output is correct |
6 | Correct | 103 ms | 12812 KB | Output is correct |
7 | Correct | 104 ms | 12808 KB | Output is correct |
8 | Correct | 77 ms | 9964 KB | Output is correct |
9 | Correct | 107 ms | 12840 KB | Output is correct |
10 | Correct | 150 ms | 12780 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 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 | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 131 ms | 12808 KB | Output is correct |
16 | Correct | 128 ms | 12748 KB | Output is correct |
17 | Correct | 74 ms | 6860 KB | Output is correct |
18 | Correct | 96 ms | 12860 KB | Output is correct |
19 | Correct | 103 ms | 12784 KB | Output is correct |
20 | Correct | 103 ms | 12812 KB | Output is correct |
21 | Correct | 104 ms | 12808 KB | Output is correct |
22 | Correct | 77 ms | 9964 KB | Output is correct |
23 | Correct | 107 ms | 12840 KB | Output is correct |
24 | Correct | 150 ms | 12780 KB | Output is correct |
25 | Correct | 144 ms | 8716 KB | Output is correct |
26 | Correct | 100 ms | 11216 KB | Output is correct |
27 | Correct | 167 ms | 11656 KB | Output is correct |
28 | Correct | 189 ms | 12232 KB | Output is correct |
29 | Correct | 93 ms | 10704 KB | Output is correct |
30 | Correct | 156 ms | 12072 KB | Output is correct |
31 | Correct | 21 ms | 1648 KB | Output is correct |
32 | Correct | 124 ms | 14896 KB | Output is correct |
33 | Correct | 226 ms | 15068 KB | Output is correct |
34 | Correct | 149 ms | 14824 KB | Output is correct |
35 | Correct | 197 ms | 15076 KB | Output is correct |
36 | Correct | 125 ms | 14788 KB | Output is correct |
37 | Correct | 230 ms | 14988 KB | Output is correct |
38 | Correct | 231 ms | 14840 KB | Output is correct |
39 | Correct | 235 ms | 15076 KB | Output is correct |
40 | Correct | 229 ms | 14928 KB | Output is correct |
41 | Correct | 216 ms | 14944 KB | Output is correct |
42 | Correct | 286 ms | 15184 KB | Output is correct |
43 | Correct | 156 ms | 14824 KB | Output is correct |
44 | Correct | 280 ms | 15212 KB | Output is correct |
45 | Correct | 175 ms | 14880 KB | Output is correct |
46 | Correct | 199 ms | 14904 KB | Output is correct |