// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
using ll = long long;
template<class T> using V = vector<T>;
using vi = V<int>;
using vl = V<ll>;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N; cin >> N;
V<vi> A(N, vi(N)); for(auto& v : A) for(auto& x : v) cin >> x;
V<vl> dp(N, vl(N));
for(int i = 1; i < N; i++) {
int b = i & (-i);
for(int nx = 0; nx < N; nx++) {
dp[i][nx] = ll(1e18);
int l = (nx ^ b) & (~(b - 1)), r = l + b - 1;
for(int x = l; x <= r; x++) dp[i][nx] = min(dp[i][nx], dp[i - 1][x] + A[nx][x]);
}
}
cout << *min_element(begin(dp[N - 1]), end(dp[N - 1])) << nl;
exit(0-0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
544 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
544 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
600 KB |
Output is correct |
22 |
Correct |
2 ms |
600 KB |
Output is correct |
23 |
Correct |
3 ms |
860 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
600 KB |
Output is correct |
27 |
Correct |
2 ms |
700 KB |
Output is correct |
28 |
Correct |
2 ms |
600 KB |
Output is correct |
29 |
Correct |
2 ms |
600 KB |
Output is correct |
30 |
Correct |
2 ms |
600 KB |
Output is correct |
31 |
Correct |
2 ms |
604 KB |
Output is correct |
32 |
Correct |
2 ms |
600 KB |
Output is correct |
33 |
Correct |
2 ms |
600 KB |
Output is correct |
34 |
Correct |
2 ms |
600 KB |
Output is correct |
35 |
Correct |
2 ms |
636 KB |
Output is correct |
36 |
Correct |
2 ms |
600 KB |
Output is correct |
37 |
Correct |
2 ms |
600 KB |
Output is correct |
38 |
Correct |
2 ms |
600 KB |
Output is correct |
39 |
Correct |
2 ms |
604 KB |
Output is correct |
40 |
Correct |
3 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
544 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
600 KB |
Output is correct |
22 |
Correct |
2 ms |
600 KB |
Output is correct |
23 |
Correct |
3 ms |
860 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
600 KB |
Output is correct |
27 |
Correct |
2 ms |
700 KB |
Output is correct |
28 |
Correct |
2 ms |
600 KB |
Output is correct |
29 |
Correct |
2 ms |
600 KB |
Output is correct |
30 |
Correct |
2 ms |
600 KB |
Output is correct |
31 |
Correct |
2 ms |
604 KB |
Output is correct |
32 |
Correct |
2 ms |
600 KB |
Output is correct |
33 |
Correct |
2 ms |
600 KB |
Output is correct |
34 |
Correct |
2 ms |
600 KB |
Output is correct |
35 |
Correct |
2 ms |
636 KB |
Output is correct |
36 |
Correct |
2 ms |
600 KB |
Output is correct |
37 |
Correct |
2 ms |
600 KB |
Output is correct |
38 |
Correct |
2 ms |
600 KB |
Output is correct |
39 |
Correct |
2 ms |
604 KB |
Output is correct |
40 |
Correct |
3 ms |
600 KB |
Output is correct |
41 |
Correct |
27 ms |
5840 KB |
Output is correct |
42 |
Correct |
24 ms |
5976 KB |
Output is correct |
43 |
Correct |
27 ms |
6100 KB |
Output is correct |
44 |
Correct |
24 ms |
6096 KB |
Output is correct |
45 |
Correct |
24 ms |
6216 KB |
Output is correct |
46 |
Correct |
23 ms |
6092 KB |
Output is correct |
47 |
Correct |
23 ms |
6108 KB |
Output is correct |
48 |
Correct |
23 ms |
5956 KB |
Output is correct |
49 |
Correct |
22 ms |
5980 KB |
Output is correct |
50 |
Correct |
30 ms |
6076 KB |
Output is correct |
51 |
Correct |
36 ms |
6092 KB |
Output is correct |
52 |
Correct |
25 ms |
5976 KB |
Output is correct |
53 |
Correct |
26 ms |
6368 KB |
Output is correct |
54 |
Correct |
25 ms |
5980 KB |
Output is correct |
55 |
Correct |
26 ms |
6096 KB |
Output is correct |
56 |
Correct |
23 ms |
6092 KB |
Output is correct |
57 |
Correct |
24 ms |
5952 KB |
Output is correct |
58 |
Correct |
26 ms |
5968 KB |
Output is correct |
59 |
Correct |
23 ms |
5980 KB |
Output is correct |
60 |
Correct |
24 ms |
6084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
544 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
600 KB |
Output is correct |
22 |
Correct |
2 ms |
600 KB |
Output is correct |
23 |
Correct |
3 ms |
860 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
2 ms |
600 KB |
Output is correct |
27 |
Correct |
2 ms |
700 KB |
Output is correct |
28 |
Correct |
2 ms |
600 KB |
Output is correct |
29 |
Correct |
2 ms |
600 KB |
Output is correct |
30 |
Correct |
2 ms |
600 KB |
Output is correct |
31 |
Correct |
2 ms |
604 KB |
Output is correct |
32 |
Correct |
2 ms |
600 KB |
Output is correct |
33 |
Correct |
2 ms |
600 KB |
Output is correct |
34 |
Correct |
2 ms |
600 KB |
Output is correct |
35 |
Correct |
2 ms |
636 KB |
Output is correct |
36 |
Correct |
2 ms |
600 KB |
Output is correct |
37 |
Correct |
2 ms |
600 KB |
Output is correct |
38 |
Correct |
2 ms |
600 KB |
Output is correct |
39 |
Correct |
2 ms |
604 KB |
Output is correct |
40 |
Correct |
3 ms |
600 KB |
Output is correct |
41 |
Correct |
27 ms |
5840 KB |
Output is correct |
42 |
Correct |
24 ms |
5976 KB |
Output is correct |
43 |
Correct |
27 ms |
6100 KB |
Output is correct |
44 |
Correct |
24 ms |
6096 KB |
Output is correct |
45 |
Correct |
24 ms |
6216 KB |
Output is correct |
46 |
Correct |
23 ms |
6092 KB |
Output is correct |
47 |
Correct |
23 ms |
6108 KB |
Output is correct |
48 |
Correct |
23 ms |
5956 KB |
Output is correct |
49 |
Correct |
22 ms |
5980 KB |
Output is correct |
50 |
Correct |
30 ms |
6076 KB |
Output is correct |
51 |
Correct |
36 ms |
6092 KB |
Output is correct |
52 |
Correct |
25 ms |
5976 KB |
Output is correct |
53 |
Correct |
26 ms |
6368 KB |
Output is correct |
54 |
Correct |
25 ms |
5980 KB |
Output is correct |
55 |
Correct |
26 ms |
6096 KB |
Output is correct |
56 |
Correct |
23 ms |
6092 KB |
Output is correct |
57 |
Correct |
24 ms |
5952 KB |
Output is correct |
58 |
Correct |
26 ms |
5968 KB |
Output is correct |
59 |
Correct |
23 ms |
5980 KB |
Output is correct |
60 |
Correct |
24 ms |
6084 KB |
Output is correct |
61 |
Correct |
409 ms |
90200 KB |
Output is correct |
62 |
Correct |
391 ms |
90308 KB |
Output is correct |
63 |
Correct |
409 ms |
90452 KB |
Output is correct |
64 |
Correct |
400 ms |
90248 KB |
Output is correct |
65 |
Correct |
408 ms |
90080 KB |
Output is correct |
66 |
Correct |
406 ms |
90080 KB |
Output is correct |
67 |
Correct |
436 ms |
90444 KB |
Output is correct |
68 |
Correct |
389 ms |
90260 KB |
Output is correct |
69 |
Correct |
391 ms |
90164 KB |
Output is correct |
70 |
Correct |
398 ms |
90624 KB |
Output is correct |
71 |
Correct |
399 ms |
90868 KB |
Output is correct |
72 |
Correct |
385 ms |
90904 KB |
Output is correct |
73 |
Correct |
403 ms |
90848 KB |
Output is correct |
74 |
Correct |
382 ms |
90904 KB |
Output is correct |
75 |
Correct |
382 ms |
91080 KB |
Output is correct |
76 |
Correct |
423 ms |
91096 KB |
Output is correct |
77 |
Correct |
388 ms |
90916 KB |
Output is correct |
78 |
Correct |
394 ms |
90736 KB |
Output is correct |
79 |
Correct |
398 ms |
91164 KB |
Output is correct |
80 |
Correct |
385 ms |
90912 KB |
Output is correct |