# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
718525 | 2023-04-04T09:28:57 Z | Augustyn | Naboj (COCI22_naboj) | C++17 | 248 ms | 15204 KB |
#include<iostream> #include<vector> using namespace std; #define x 200001 int n,m; vector<int>pol[x]; bool juzodw[x],terodw[x]; int stp_wch[x],odp[x],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); 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]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 3 ms | 4948 KB | Output is correct |
3 | Correct | 3 ms | 4948 KB | Output is correct |
4 | Correct | 4 ms | 4948 KB | Output is correct |
5 | Correct | 3 ms | 4948 KB | Output is correct |
6 | Correct | 3 ms | 4948 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 2 ms | 4948 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 3 ms | 4920 KB | Output is correct |
11 | Correct | 3 ms | 4948 KB | Output is correct |
12 | Correct | 3 ms | 4948 KB | Output is correct |
13 | Correct | 3 ms | 4948 KB | Output is correct |
14 | Correct | 2 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 108 ms | 12852 KB | Output is correct |
2 | Correct | 106 ms | 12876 KB | Output is correct |
3 | Correct | 50 ms | 9044 KB | Output is correct |
4 | Correct | 112 ms | 12788 KB | Output is correct |
5 | Correct | 107 ms | 12756 KB | Output is correct |
6 | Correct | 104 ms | 12732 KB | Output is correct |
7 | Correct | 113 ms | 12768 KB | Output is correct |
8 | Correct | 88 ms | 11124 KB | Output is correct |
9 | Correct | 110 ms | 12760 KB | Output is correct |
10 | Correct | 98 ms | 12804 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 3 ms | 4948 KB | Output is correct |
3 | Correct | 3 ms | 4948 KB | Output is correct |
4 | Correct | 4 ms | 4948 KB | Output is correct |
5 | Correct | 3 ms | 4948 KB | Output is correct |
6 | Correct | 3 ms | 4948 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 2 ms | 4948 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 3 ms | 4920 KB | Output is correct |
11 | Correct | 3 ms | 4948 KB | Output is correct |
12 | Correct | 3 ms | 4948 KB | Output is correct |
13 | Correct | 3 ms | 4948 KB | Output is correct |
14 | Correct | 2 ms | 4948 KB | Output is correct |
15 | Correct | 108 ms | 12852 KB | Output is correct |
16 | Correct | 106 ms | 12876 KB | Output is correct |
17 | Correct | 50 ms | 9044 KB | Output is correct |
18 | Correct | 112 ms | 12788 KB | Output is correct |
19 | Correct | 107 ms | 12756 KB | Output is correct |
20 | Correct | 104 ms | 12732 KB | Output is correct |
21 | Correct | 113 ms | 12768 KB | Output is correct |
22 | Correct | 88 ms | 11124 KB | Output is correct |
23 | Correct | 110 ms | 12760 KB | Output is correct |
24 | Correct | 98 ms | 12804 KB | Output is correct |
25 | Correct | 148 ms | 10288 KB | Output is correct |
26 | Correct | 101 ms | 11104 KB | Output is correct |
27 | Correct | 158 ms | 11676 KB | Output is correct |
28 | Correct | 184 ms | 12152 KB | Output is correct |
29 | Correct | 100 ms | 10804 KB | Output is correct |
30 | Correct | 185 ms | 12108 KB | Output is correct |
31 | Correct | 25 ms | 5972 KB | Output is correct |
32 | Correct | 125 ms | 14892 KB | Output is correct |
33 | Correct | 212 ms | 15104 KB | Output is correct |
34 | Correct | 160 ms | 14868 KB | Output is correct |
35 | Correct | 248 ms | 15076 KB | Output is correct |
36 | Correct | 118 ms | 14772 KB | Output is correct |
37 | Correct | 183 ms | 14968 KB | Output is correct |
38 | Correct | 161 ms | 14888 KB | Output is correct |
39 | Correct | 191 ms | 15088 KB | Output is correct |
40 | Correct | 197 ms | 14868 KB | Output is correct |
41 | Correct | 184 ms | 14924 KB | Output is correct |
42 | Correct | 236 ms | 15160 KB | Output is correct |
43 | Correct | 131 ms | 14788 KB | Output is correct |
44 | Correct | 201 ms | 15204 KB | Output is correct |
45 | Correct | 116 ms | 14796 KB | Output is correct |
46 | Correct | 173 ms | 14984 KB | Output is correct |