답안 #848364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
848364 2023-09-12T09:19:41 Z patrikpavic2 Netrpeljivost (COI23_netrpeljivost) C++17
100 / 100
474 ms 91152 KB
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const int N = 2050;
const int INF = 0x3f3f3f3f;

int n, cst[N][N];
ll dp[N][N];

int main(){
	scanf("%d", &n);
	for(int i = 0;i < n;i++) {
		for(int j = 0;j < n;j++) {
			scanf("%d", &cst[i][j]);
		}
	}
	for(int p = 1;p < n;p++) {
		int ch = p & (-p);
		for(int z = 0;z < n;z++) {
			dp[p][z] = (ll)1e18;
			int zz = (z ^ ch) & (~(ch - 1));
			for(int t = zz;t < zz + ch;t++)
				dp[p][z] = min(dp[p][z], dp[p - 1][t] + cst[t][z]);
		}
	}
	ll sol = (ll)1e18;
	for(int i = 0;i < n;i++)
		sol = min(sol, dp[n - 1][i]);
	printf("%lld\n", sol);
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
Main.cpp:18:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |    scanf("%d", &cst[i][j]);
      |    ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2728 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2472 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 0 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2728 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2472 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 0 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 3 ms 4952 KB Output is correct
22 Correct 3 ms 5108 KB Output is correct
23 Correct 2 ms 4952 KB Output is correct
24 Correct 1 ms 2652 KB Output is correct
25 Correct 2 ms 2648 KB Output is correct
26 Correct 2 ms 4952 KB Output is correct
27 Correct 3 ms 4952 KB Output is correct
28 Correct 2 ms 4952 KB Output is correct
29 Correct 2 ms 4952 KB Output is correct
30 Correct 4 ms 4952 KB Output is correct
31 Correct 2 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
33 Correct 2 ms 4952 KB Output is correct
34 Correct 2 ms 4952 KB Output is correct
35 Correct 2 ms 4952 KB Output is correct
36 Correct 2 ms 4952 KB Output is correct
37 Correct 2 ms 4952 KB Output is correct
38 Correct 2 ms 4952 KB Output is correct
39 Correct 2 ms 4952 KB Output is correct
40 Correct 3 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2728 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2472 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 0 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 3 ms 4952 KB Output is correct
22 Correct 3 ms 5108 KB Output is correct
23 Correct 2 ms 4952 KB Output is correct
24 Correct 1 ms 2652 KB Output is correct
25 Correct 2 ms 2648 KB Output is correct
26 Correct 2 ms 4952 KB Output is correct
27 Correct 3 ms 4952 KB Output is correct
28 Correct 2 ms 4952 KB Output is correct
29 Correct 2 ms 4952 KB Output is correct
30 Correct 4 ms 4952 KB Output is correct
31 Correct 2 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
33 Correct 2 ms 4952 KB Output is correct
34 Correct 2 ms 4952 KB Output is correct
35 Correct 2 ms 4952 KB Output is correct
36 Correct 2 ms 4952 KB Output is correct
37 Correct 2 ms 4952 KB Output is correct
38 Correct 2 ms 4952 KB Output is correct
39 Correct 2 ms 4952 KB Output is correct
40 Correct 3 ms 4952 KB Output is correct
41 Correct 25 ms 17780 KB Output is correct
42 Correct 25 ms 17744 KB Output is correct
43 Correct 26 ms 17744 KB Output is correct
44 Correct 24 ms 17744 KB Output is correct
45 Correct 29 ms 17752 KB Output is correct
46 Correct 25 ms 17744 KB Output is correct
47 Correct 25 ms 17820 KB Output is correct
48 Correct 24 ms 17816 KB Output is correct
49 Correct 24 ms 17680 KB Output is correct
50 Correct 24 ms 17680 KB Output is correct
51 Correct 26 ms 18000 KB Output is correct
52 Correct 24 ms 17752 KB Output is correct
53 Correct 24 ms 17744 KB Output is correct
54 Correct 24 ms 17808 KB Output is correct
55 Correct 24 ms 17880 KB Output is correct
56 Correct 25 ms 17744 KB Output is correct
57 Correct 25 ms 17744 KB Output is correct
58 Correct 24 ms 17828 KB Output is correct
59 Correct 24 ms 17744 KB Output is correct
60 Correct 24 ms 17744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2728 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2472 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 0 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 3 ms 4952 KB Output is correct
22 Correct 3 ms 5108 KB Output is correct
23 Correct 2 ms 4952 KB Output is correct
24 Correct 1 ms 2652 KB Output is correct
25 Correct 2 ms 2648 KB Output is correct
26 Correct 2 ms 4952 KB Output is correct
27 Correct 3 ms 4952 KB Output is correct
28 Correct 2 ms 4952 KB Output is correct
29 Correct 2 ms 4952 KB Output is correct
30 Correct 4 ms 4952 KB Output is correct
31 Correct 2 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
33 Correct 2 ms 4952 KB Output is correct
34 Correct 2 ms 4952 KB Output is correct
35 Correct 2 ms 4952 KB Output is correct
36 Correct 2 ms 4952 KB Output is correct
37 Correct 2 ms 4952 KB Output is correct
38 Correct 2 ms 4952 KB Output is correct
39 Correct 2 ms 4952 KB Output is correct
40 Correct 3 ms 4952 KB Output is correct
41 Correct 25 ms 17780 KB Output is correct
42 Correct 25 ms 17744 KB Output is correct
43 Correct 26 ms 17744 KB Output is correct
44 Correct 24 ms 17744 KB Output is correct
45 Correct 29 ms 17752 KB Output is correct
46 Correct 25 ms 17744 KB Output is correct
47 Correct 25 ms 17820 KB Output is correct
48 Correct 24 ms 17816 KB Output is correct
49 Correct 24 ms 17680 KB Output is correct
50 Correct 24 ms 17680 KB Output is correct
51 Correct 26 ms 18000 KB Output is correct
52 Correct 24 ms 17752 KB Output is correct
53 Correct 24 ms 17744 KB Output is correct
54 Correct 24 ms 17808 KB Output is correct
55 Correct 24 ms 17880 KB Output is correct
56 Correct 25 ms 17744 KB Output is correct
57 Correct 25 ms 17744 KB Output is correct
58 Correct 24 ms 17828 KB Output is correct
59 Correct 24 ms 17744 KB Output is correct
60 Correct 24 ms 17744 KB Output is correct
61 Correct 370 ms 90088 KB Output is correct
62 Correct 376 ms 89972 KB Output is correct
63 Correct 431 ms 89992 KB Output is correct
64 Correct 374 ms 89888 KB Output is correct
65 Correct 389 ms 90068 KB Output is correct
66 Correct 374 ms 90116 KB Output is correct
67 Correct 370 ms 90072 KB Output is correct
68 Correct 386 ms 90124 KB Output is correct
69 Correct 373 ms 89972 KB Output is correct
70 Correct 380 ms 90448 KB Output is correct
71 Correct 474 ms 90404 KB Output is correct
72 Correct 375 ms 90800 KB Output is correct
73 Correct 379 ms 90544 KB Output is correct
74 Correct 401 ms 90564 KB Output is correct
75 Correct 377 ms 90540 KB Output is correct
76 Correct 384 ms 90968 KB Output is correct
77 Correct 384 ms 90588 KB Output is correct
78 Correct 391 ms 91152 KB Output is correct
79 Correct 381 ms 90516 KB Output is correct
80 Correct 370 ms 90720 KB Output is correct