# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
718530 | 2023-04-04T09:34:37 Z | Augustyn | Naboj (COCI22_naboj) | C++17 | 289 ms | 17180 KB |
#include<bits/stdc++.h> using namespace std; #define x 200001 int n,m,sw[x],odp[x],it; vector<int>p[x]; bool jo[x],to[x]; bool c; void dfs(int t) { jo[t]=to[t]=1; for(int i:p[t]) { if(to[i]==1) c=1; else if(jo[i]==0) dfs(i); } to[t]=0; odp[++it]=t; } int main() { scanf("%d%d",&n,&m); while(m--) { int a,b; scanf("%d%d",&a,&b); p[b].push_back(a); sw[a]++; } for(int i=1;i<=n;++i) if(sw[i]==0) dfs(i); if(it!=n) c=1; if(c) { printf("-1"); return 0; } printf("%d\n",n); for(int i=1;i<=n;++i) printf("%d 0\n",odp[i]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | 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 | 3 ms | 4948 KB | Output is correct |
5 | Correct | 2 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 | 3 ms | 4948 KB | Output is correct |
9 | Correct | 3 ms | 4948 KB | Output is correct |
10 | Correct | 2 ms | 4948 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 108 ms | 12844 KB | Output is correct |
2 | Correct | 117 ms | 12812 KB | Output is correct |
3 | Correct | 50 ms | 9008 KB | Output is correct |
4 | Correct | 123 ms | 12804 KB | Output is correct |
5 | Correct | 101 ms | 12744 KB | Output is correct |
6 | Correct | 107 ms | 12748 KB | Output is correct |
7 | Correct | 120 ms | 12836 KB | Output is correct |
8 | Correct | 94 ms | 11232 KB | Output is correct |
9 | Correct | 134 ms | 12748 KB | Output is correct |
10 | Correct | 108 ms | 12768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 3 ms | 4948 KB | Output is correct |
5 | Correct | 2 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 | 3 ms | 4948 KB | Output is correct |
9 | Correct | 3 ms | 4948 KB | Output is correct |
10 | Correct | 2 ms | 4948 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 | 12844 KB | Output is correct |
16 | Correct | 117 ms | 12812 KB | Output is correct |
17 | Correct | 50 ms | 9008 KB | Output is correct |
18 | Correct | 123 ms | 12804 KB | Output is correct |
19 | Correct | 101 ms | 12744 KB | Output is correct |
20 | Correct | 107 ms | 12748 KB | Output is correct |
21 | Correct | 120 ms | 12836 KB | Output is correct |
22 | Correct | 94 ms | 11232 KB | Output is correct |
23 | Correct | 134 ms | 12748 KB | Output is correct |
24 | Correct | 108 ms | 12768 KB | Output is correct |
25 | Correct | 221 ms | 14876 KB | Output is correct |
26 | Correct | 136 ms | 13080 KB | Output is correct |
27 | Correct | 212 ms | 14940 KB | Output is correct |
28 | Correct | 193 ms | 17180 KB | Output is correct |
29 | Correct | 170 ms | 11724 KB | Output is correct |
30 | Correct | 218 ms | 16988 KB | Output is correct |
31 | Correct | 26 ms | 6784 KB | Output is correct |
32 | Correct | 138 ms | 14860 KB | Output is correct |
33 | Correct | 224 ms | 15012 KB | Output is correct |
34 | Correct | 135 ms | 14832 KB | Output is correct |
35 | Correct | 289 ms | 15008 KB | Output is correct |
36 | Correct | 138 ms | 14896 KB | Output is correct |
37 | Correct | 193 ms | 15004 KB | Output is correct |
38 | Correct | 192 ms | 14840 KB | Output is correct |
39 | Correct | 240 ms | 15052 KB | Output is correct |
40 | Correct | 181 ms | 14976 KB | Output is correct |
41 | Correct | 184 ms | 14964 KB | Output is correct |
42 | Correct | 215 ms | 15180 KB | Output is correct |
43 | Correct | 180 ms | 14796 KB | Output is correct |
44 | Correct | 244 ms | 15152 KB | Output is correct |
45 | Correct | 139 ms | 14868 KB | Output is correct |
46 | Correct | 181 ms | 14880 KB | Output is correct |