# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
810606 | 2023-08-06T12:10:02 Z | rainboy | Netrpeljivost (COI23_netrpeljivost) | C | 861 ms | 95400 KB |
#include <stdio.h> #include <string.h> #define N 2048 #define INF 0x3f3f3f3f3f3f3f3fLL long long min(long long a, long long b) { return a < b ? a : b; } int main() { static int ww[N][N]; static long long dp[N][N], dq[N][N], xx[N]; int n, h, i, j, k, l, m, r, lm, mr; long long ans; scanf("%d", &n); for (i = 0; i < n; i++) for (j = 0; j < n; j++) scanf("%d", &ww[i][j]); if (n == 1) { printf("0\n"); return 0; } if (n == 2) { printf("%d\n", ww[0][1]); return 0; } for (h = 0; 1 << h < n / 2; h++) if (h == 0) for (i = 0; i < n; i += 2) { j = i + 1; dp[i][j] = ww[i][j]; } else for (l = 0; l < n; l = r) { r = l + (1 << h + 1), m = l + (1 << h), lm = l + (1 << h - 1), mr = m + (1 << h - 1); for (i = l; i < m; i++) memset(dq[i] + m, 0x3f, (r - m) * sizeof *dq[i]); for (i = l; i < lm; i++) for (j = lm; j < m; j++) for (k = m; k < r; k++) { dq[i][k] = min(dq[i][k], dp[i][j] + ww[j][k]); dq[j][k] = min(dq[j][k], dp[i][j] + ww[i][k]); } for (i = l; i < m; i++) memset(dp[i] + m, 0x3f, (r - m) * sizeof *dp[i]); for (i = l; i < m; i++) for (j = m; j < mr; j++) for (k = mr; k < r; k++) { dp[i][k] = min(dp[i][k], dq[i][j] + dp[j][k]); dp[i][j] = min(dp[i][j], dq[i][k] + dp[j][k]); } } l = 0, r = l + (1 << h + 1), m = l + (1 << h), lm = l + (1 << h - 1), mr = m + (1 << h - 1); memset(xx + l, 0x3f, (r - l) * sizeof *xx); for (i = l; i < lm; i++) for (j = lm; j < m; j++) { xx[i] = min(xx[i], dp[i][j]); xx[j] = min(xx[j], dp[i][j]); } for (i = m; i < mr; i++) for (j = mr; j < r; j++) { xx[i] = min(xx[i], dp[i][j]); xx[j] = min(xx[j], dp[i][j]); } ans = INF; for (i = l; i < m; i++) for (j = m; j < r; j++) ans = min(ans, xx[i] + ww[i][j] + xx[j]); printf("%lld\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 0 ms | 420 KB | Output is correct |
3 | Correct | 1 ms | 424 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 420 KB | Output is correct |
7 | Correct | 1 ms | 420 KB | Output is correct |
8 | Correct | 0 ms | 468 KB | Output is correct |
9 | Correct | 0 ms | 468 KB | Output is correct |
10 | Correct | 0 ms | 468 KB | Output is correct |
11 | Correct | 0 ms | 464 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 352 KB | Output is correct |
14 | Correct | 1 ms | 468 KB | Output is correct |
15 | Correct | 1 ms | 468 KB | Output is correct |
16 | Correct | 1 ms | 468 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 420 KB | Output is correct |
20 | Correct | 0 ms | 468 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 0 ms | 420 KB | Output is correct |
3 | Correct | 1 ms | 424 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 420 KB | Output is correct |
7 | Correct | 1 ms | 420 KB | Output is correct |
8 | Correct | 0 ms | 468 KB | Output is correct |
9 | Correct | 0 ms | 468 KB | Output is correct |
10 | Correct | 0 ms | 468 KB | Output is correct |
11 | Correct | 0 ms | 464 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 352 KB | Output is correct |
14 | Correct | 1 ms | 468 KB | Output is correct |
15 | Correct | 1 ms | 468 KB | Output is correct |
16 | Correct | 1 ms | 468 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 420 KB | Output is correct |
20 | Correct | 0 ms | 468 KB | Output is correct |
21 | Correct | 5 ms | 1780 KB | Output is correct |
22 | Correct | 5 ms | 1812 KB | Output is correct |
23 | Correct | 4 ms | 1804 KB | Output is correct |
24 | Correct | 2 ms | 980 KB | Output is correct |
25 | Correct | 2 ms | 996 KB | Output is correct |
26 | Correct | 4 ms | 1876 KB | Output is correct |
27 | Correct | 5 ms | 1852 KB | Output is correct |
28 | Correct | 4 ms | 1880 KB | Output is correct |
29 | Correct | 3 ms | 1876 KB | Output is correct |
30 | Correct | 6 ms | 1808 KB | Output is correct |
31 | Correct | 5 ms | 1920 KB | Output is correct |
32 | Correct | 4 ms | 1856 KB | Output is correct |
33 | Correct | 4 ms | 1876 KB | Output is correct |
34 | Correct | 4 ms | 1876 KB | Output is correct |
35 | Correct | 5 ms | 1840 KB | Output is correct |
36 | Correct | 5 ms | 1844 KB | Output is correct |
37 | Correct | 3 ms | 1876 KB | Output is correct |
38 | Correct | 8 ms | 1748 KB | Output is correct |
39 | Correct | 5 ms | 1832 KB | Output is correct |
40 | Correct | 5 ms | 1876 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 0 ms | 420 KB | Output is correct |
3 | Correct | 1 ms | 424 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 420 KB | Output is correct |
7 | Correct | 1 ms | 420 KB | Output is correct |
8 | Correct | 0 ms | 468 KB | Output is correct |
9 | Correct | 0 ms | 468 KB | Output is correct |
10 | Correct | 0 ms | 468 KB | Output is correct |
11 | Correct | 0 ms | 464 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 352 KB | Output is correct |
14 | Correct | 1 ms | 468 KB | Output is correct |
15 | Correct | 1 ms | 468 KB | Output is correct |
16 | Correct | 1 ms | 468 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 420 KB | Output is correct |
20 | Correct | 0 ms | 468 KB | Output is correct |
21 | Correct | 5 ms | 1780 KB | Output is correct |
22 | Correct | 5 ms | 1812 KB | Output is correct |
23 | Correct | 4 ms | 1804 KB | Output is correct |
24 | Correct | 2 ms | 980 KB | Output is correct |
25 | Correct | 2 ms | 996 KB | Output is correct |
26 | Correct | 4 ms | 1876 KB | Output is correct |
27 | Correct | 5 ms | 1852 KB | Output is correct |
28 | Correct | 4 ms | 1880 KB | Output is correct |
29 | Correct | 3 ms | 1876 KB | Output is correct |
30 | Correct | 6 ms | 1808 KB | Output is correct |
31 | Correct | 5 ms | 1920 KB | Output is correct |
32 | Correct | 4 ms | 1856 KB | Output is correct |
33 | Correct | 4 ms | 1876 KB | Output is correct |
34 | Correct | 4 ms | 1876 KB | Output is correct |
35 | Correct | 5 ms | 1840 KB | Output is correct |
36 | Correct | 5 ms | 1844 KB | Output is correct |
37 | Correct | 3 ms | 1876 KB | Output is correct |
38 | Correct | 8 ms | 1748 KB | Output is correct |
39 | Correct | 5 ms | 1832 KB | Output is correct |
40 | Correct | 5 ms | 1876 KB | Output is correct |
41 | Correct | 48 ms | 9084 KB | Output is correct |
42 | Correct | 51 ms | 9620 KB | Output is correct |
43 | Correct | 48 ms | 9132 KB | Output is correct |
44 | Correct | 97 ms | 7940 KB | Output is correct |
45 | Correct | 67 ms | 8408 KB | Output is correct |
46 | Correct | 40 ms | 9708 KB | Output is correct |
47 | Correct | 85 ms | 8168 KB | Output is correct |
48 | Correct | 48 ms | 9768 KB | Output is correct |
49 | Correct | 61 ms | 8584 KB | Output is correct |
50 | Correct | 87 ms | 7744 KB | Output is correct |
51 | Correct | 77 ms | 7804 KB | Output is correct |
52 | Correct | 73 ms | 7752 KB | Output is correct |
53 | Correct | 62 ms | 7756 KB | Output is correct |
54 | Correct | 81 ms | 7804 KB | Output is correct |
55 | Correct | 108 ms | 7788 KB | Output is correct |
56 | Correct | 56 ms | 10008 KB | Output is correct |
57 | Correct | 39 ms | 10232 KB | Output is correct |
58 | Correct | 37 ms | 10188 KB | Output is correct |
59 | Correct | 30 ms | 10264 KB | Output is correct |
60 | Correct | 35 ms | 10168 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 0 ms | 420 KB | Output is correct |
3 | Correct | 1 ms | 424 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 468 KB | Output is correct |
6 | Correct | 1 ms | 420 KB | Output is correct |
7 | Correct | 1 ms | 420 KB | Output is correct |
8 | Correct | 0 ms | 468 KB | Output is correct |
9 | Correct | 0 ms | 468 KB | Output is correct |
10 | Correct | 0 ms | 468 KB | Output is correct |
11 | Correct | 0 ms | 464 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 352 KB | Output is correct |
14 | Correct | 1 ms | 468 KB | Output is correct |
15 | Correct | 1 ms | 468 KB | Output is correct |
16 | Correct | 1 ms | 468 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 420 KB | Output is correct |
20 | Correct | 0 ms | 468 KB | Output is correct |
21 | Correct | 5 ms | 1780 KB | Output is correct |
22 | Correct | 5 ms | 1812 KB | Output is correct |
23 | Correct | 4 ms | 1804 KB | Output is correct |
24 | Correct | 2 ms | 980 KB | Output is correct |
25 | Correct | 2 ms | 996 KB | Output is correct |
26 | Correct | 4 ms | 1876 KB | Output is correct |
27 | Correct | 5 ms | 1852 KB | Output is correct |
28 | Correct | 4 ms | 1880 KB | Output is correct |
29 | Correct | 3 ms | 1876 KB | Output is correct |
30 | Correct | 6 ms | 1808 KB | Output is correct |
31 | Correct | 5 ms | 1920 KB | Output is correct |
32 | Correct | 4 ms | 1856 KB | Output is correct |
33 | Correct | 4 ms | 1876 KB | Output is correct |
34 | Correct | 4 ms | 1876 KB | Output is correct |
35 | Correct | 5 ms | 1840 KB | Output is correct |
36 | Correct | 5 ms | 1844 KB | Output is correct |
37 | Correct | 3 ms | 1876 KB | Output is correct |
38 | Correct | 8 ms | 1748 KB | Output is correct |
39 | Correct | 5 ms | 1832 KB | Output is correct |
40 | Correct | 5 ms | 1876 KB | Output is correct |
41 | Correct | 48 ms | 9084 KB | Output is correct |
42 | Correct | 51 ms | 9620 KB | Output is correct |
43 | Correct | 48 ms | 9132 KB | Output is correct |
44 | Correct | 97 ms | 7940 KB | Output is correct |
45 | Correct | 67 ms | 8408 KB | Output is correct |
46 | Correct | 40 ms | 9708 KB | Output is correct |
47 | Correct | 85 ms | 8168 KB | Output is correct |
48 | Correct | 48 ms | 9768 KB | Output is correct |
49 | Correct | 61 ms | 8584 KB | Output is correct |
50 | Correct | 87 ms | 7744 KB | Output is correct |
51 | Correct | 77 ms | 7804 KB | Output is correct |
52 | Correct | 73 ms | 7752 KB | Output is correct |
53 | Correct | 62 ms | 7756 KB | Output is correct |
54 | Correct | 81 ms | 7804 KB | Output is correct |
55 | Correct | 108 ms | 7788 KB | Output is correct |
56 | Correct | 56 ms | 10008 KB | Output is correct |
57 | Correct | 39 ms | 10232 KB | Output is correct |
58 | Correct | 37 ms | 10188 KB | Output is correct |
59 | Correct | 30 ms | 10264 KB | Output is correct |
60 | Correct | 35 ms | 10168 KB | Output is correct |
61 | Correct | 776 ms | 94976 KB | Output is correct |
62 | Correct | 741 ms | 95400 KB | Output is correct |
63 | Correct | 717 ms | 95400 KB | Output is correct |
64 | Correct | 755 ms | 95324 KB | Output is correct |
65 | Correct | 780 ms | 93436 KB | Output is correct |
66 | Correct | 727 ms | 92236 KB | Output is correct |
67 | Correct | 724 ms | 95180 KB | Output is correct |
68 | Correct | 754 ms | 95216 KB | Output is correct |
69 | Correct | 757 ms | 95384 KB | Output is correct |
70 | Correct | 751 ms | 95192 KB | Output is correct |
71 | Correct | 781 ms | 95064 KB | Output is correct |
72 | Correct | 756 ms | 93464 KB | Output is correct |
73 | Correct | 803 ms | 92416 KB | Output is correct |
74 | Correct | 793 ms | 93912 KB | Output is correct |
75 | Correct | 742 ms | 95140 KB | Output is correct |
76 | Correct | 794 ms | 94760 KB | Output is correct |
77 | Correct | 861 ms | 91220 KB | Output is correct |
78 | Correct | 836 ms | 93112 KB | Output is correct |
79 | Correct | 826 ms | 92732 KB | Output is correct |
80 | Correct | 806 ms | 92024 KB | Output is correct |