#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=0;i<n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
#define _ << " " <<
const lo inf = 1000000000000000000;
const lo li = 2050;
const lo mod = 1000000007;
int n,m,a[li][li],k,flag,t,p[li],l[li],r[li],num[li],dp[li][li];
int cev;
string s;
vector<int> v;
int32_t main(void){
fio();
cin>>n;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
FOR{
for(int j=0;j<n;j++)cin>>a[i][j];
}
cev=inf;
for(int i=1;i<n;i++){
int msd=i&(-i);
for(int x=0;x<n;x++){
int l=(x^msd)&(~(msd-1));
int r=msd+l-1;
dp[i][x]=inf;
for(int xx=l;xx<=r;xx++){
dp[i][x]=min(dp[i][x],dp[i-1][xx]+a[x][xx]);
if(i==n-1)cev=min(cev,dp[i][x]);
}
}
}
cout<<cev<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
1 ms |
6492 KB |
Output is correct |
16 |
Correct |
1 ms |
6492 KB |
Output is correct |
17 |
Correct |
1 ms |
6492 KB |
Output is correct |
18 |
Correct |
1 ms |
6492 KB |
Output is correct |
19 |
Correct |
1 ms |
6492 KB |
Output is correct |
20 |
Correct |
1 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
1 ms |
6492 KB |
Output is correct |
16 |
Correct |
1 ms |
6492 KB |
Output is correct |
17 |
Correct |
1 ms |
6492 KB |
Output is correct |
18 |
Correct |
1 ms |
6492 KB |
Output is correct |
19 |
Correct |
1 ms |
6492 KB |
Output is correct |
20 |
Correct |
1 ms |
6492 KB |
Output is correct |
21 |
Correct |
3 ms |
6488 KB |
Output is correct |
22 |
Correct |
3 ms |
6488 KB |
Output is correct |
23 |
Correct |
2 ms |
6492 KB |
Output is correct |
24 |
Correct |
1 ms |
6492 KB |
Output is correct |
25 |
Correct |
1 ms |
6492 KB |
Output is correct |
26 |
Correct |
2 ms |
6492 KB |
Output is correct |
27 |
Correct |
2 ms |
6492 KB |
Output is correct |
28 |
Correct |
2 ms |
6492 KB |
Output is correct |
29 |
Correct |
2 ms |
6492 KB |
Output is correct |
30 |
Correct |
2 ms |
6664 KB |
Output is correct |
31 |
Correct |
5 ms |
6668 KB |
Output is correct |
32 |
Correct |
2 ms |
6492 KB |
Output is correct |
33 |
Correct |
2 ms |
6492 KB |
Output is correct |
34 |
Correct |
2 ms |
6492 KB |
Output is correct |
35 |
Correct |
2 ms |
6492 KB |
Output is correct |
36 |
Correct |
2 ms |
6492 KB |
Output is correct |
37 |
Correct |
2 ms |
6492 KB |
Output is correct |
38 |
Correct |
2 ms |
6492 KB |
Output is correct |
39 |
Correct |
2 ms |
6492 KB |
Output is correct |
40 |
Correct |
2 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
1 ms |
6492 KB |
Output is correct |
16 |
Correct |
1 ms |
6492 KB |
Output is correct |
17 |
Correct |
1 ms |
6492 KB |
Output is correct |
18 |
Correct |
1 ms |
6492 KB |
Output is correct |
19 |
Correct |
1 ms |
6492 KB |
Output is correct |
20 |
Correct |
1 ms |
6492 KB |
Output is correct |
21 |
Correct |
3 ms |
6488 KB |
Output is correct |
22 |
Correct |
3 ms |
6488 KB |
Output is correct |
23 |
Correct |
2 ms |
6492 KB |
Output is correct |
24 |
Correct |
1 ms |
6492 KB |
Output is correct |
25 |
Correct |
1 ms |
6492 KB |
Output is correct |
26 |
Correct |
2 ms |
6492 KB |
Output is correct |
27 |
Correct |
2 ms |
6492 KB |
Output is correct |
28 |
Correct |
2 ms |
6492 KB |
Output is correct |
29 |
Correct |
2 ms |
6492 KB |
Output is correct |
30 |
Correct |
2 ms |
6664 KB |
Output is correct |
31 |
Correct |
5 ms |
6668 KB |
Output is correct |
32 |
Correct |
2 ms |
6492 KB |
Output is correct |
33 |
Correct |
2 ms |
6492 KB |
Output is correct |
34 |
Correct |
2 ms |
6492 KB |
Output is correct |
35 |
Correct |
2 ms |
6492 KB |
Output is correct |
36 |
Correct |
2 ms |
6492 KB |
Output is correct |
37 |
Correct |
2 ms |
6492 KB |
Output is correct |
38 |
Correct |
2 ms |
6492 KB |
Output is correct |
39 |
Correct |
2 ms |
6492 KB |
Output is correct |
40 |
Correct |
2 ms |
6492 KB |
Output is correct |
41 |
Correct |
19 ms |
18780 KB |
Output is correct |
42 |
Correct |
23 ms |
21216 KB |
Output is correct |
43 |
Correct |
21 ms |
21212 KB |
Output is correct |
44 |
Correct |
21 ms |
21188 KB |
Output is correct |
45 |
Correct |
21 ms |
21072 KB |
Output is correct |
46 |
Correct |
21 ms |
21072 KB |
Output is correct |
47 |
Correct |
28 ms |
21280 KB |
Output is correct |
48 |
Correct |
20 ms |
21072 KB |
Output is correct |
49 |
Correct |
21 ms |
21072 KB |
Output is correct |
50 |
Correct |
21 ms |
21072 KB |
Output is correct |
51 |
Correct |
21 ms |
21076 KB |
Output is correct |
52 |
Correct |
20 ms |
21072 KB |
Output is correct |
53 |
Correct |
20 ms |
21156 KB |
Output is correct |
54 |
Correct |
22 ms |
21076 KB |
Output is correct |
55 |
Correct |
20 ms |
21084 KB |
Output is correct |
56 |
Correct |
20 ms |
21084 KB |
Output is correct |
57 |
Correct |
21 ms |
21300 KB |
Output is correct |
58 |
Correct |
22 ms |
21048 KB |
Output is correct |
59 |
Correct |
20 ms |
21076 KB |
Output is correct |
60 |
Correct |
20 ms |
21104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
1 ms |
6492 KB |
Output is correct |
16 |
Correct |
1 ms |
6492 KB |
Output is correct |
17 |
Correct |
1 ms |
6492 KB |
Output is correct |
18 |
Correct |
1 ms |
6492 KB |
Output is correct |
19 |
Correct |
1 ms |
6492 KB |
Output is correct |
20 |
Correct |
1 ms |
6492 KB |
Output is correct |
21 |
Correct |
3 ms |
6488 KB |
Output is correct |
22 |
Correct |
3 ms |
6488 KB |
Output is correct |
23 |
Correct |
2 ms |
6492 KB |
Output is correct |
24 |
Correct |
1 ms |
6492 KB |
Output is correct |
25 |
Correct |
1 ms |
6492 KB |
Output is correct |
26 |
Correct |
2 ms |
6492 KB |
Output is correct |
27 |
Correct |
2 ms |
6492 KB |
Output is correct |
28 |
Correct |
2 ms |
6492 KB |
Output is correct |
29 |
Correct |
2 ms |
6492 KB |
Output is correct |
30 |
Correct |
2 ms |
6664 KB |
Output is correct |
31 |
Correct |
5 ms |
6668 KB |
Output is correct |
32 |
Correct |
2 ms |
6492 KB |
Output is correct |
33 |
Correct |
2 ms |
6492 KB |
Output is correct |
34 |
Correct |
2 ms |
6492 KB |
Output is correct |
35 |
Correct |
2 ms |
6492 KB |
Output is correct |
36 |
Correct |
2 ms |
6492 KB |
Output is correct |
37 |
Correct |
2 ms |
6492 KB |
Output is correct |
38 |
Correct |
2 ms |
6492 KB |
Output is correct |
39 |
Correct |
2 ms |
6492 KB |
Output is correct |
40 |
Correct |
2 ms |
6492 KB |
Output is correct |
41 |
Correct |
19 ms |
18780 KB |
Output is correct |
42 |
Correct |
23 ms |
21216 KB |
Output is correct |
43 |
Correct |
21 ms |
21212 KB |
Output is correct |
44 |
Correct |
21 ms |
21188 KB |
Output is correct |
45 |
Correct |
21 ms |
21072 KB |
Output is correct |
46 |
Correct |
21 ms |
21072 KB |
Output is correct |
47 |
Correct |
28 ms |
21280 KB |
Output is correct |
48 |
Correct |
20 ms |
21072 KB |
Output is correct |
49 |
Correct |
21 ms |
21072 KB |
Output is correct |
50 |
Correct |
21 ms |
21072 KB |
Output is correct |
51 |
Correct |
21 ms |
21076 KB |
Output is correct |
52 |
Correct |
20 ms |
21072 KB |
Output is correct |
53 |
Correct |
20 ms |
21156 KB |
Output is correct |
54 |
Correct |
22 ms |
21076 KB |
Output is correct |
55 |
Correct |
20 ms |
21084 KB |
Output is correct |
56 |
Correct |
20 ms |
21084 KB |
Output is correct |
57 |
Correct |
21 ms |
21300 KB |
Output is correct |
58 |
Correct |
22 ms |
21048 KB |
Output is correct |
59 |
Correct |
20 ms |
21076 KB |
Output is correct |
60 |
Correct |
20 ms |
21104 KB |
Output is correct |
61 |
Correct |
332 ms |
96984 KB |
Output is correct |
62 |
Correct |
310 ms |
96848 KB |
Output is correct |
63 |
Correct |
305 ms |
97116 KB |
Output is correct |
64 |
Correct |
351 ms |
96852 KB |
Output is correct |
65 |
Correct |
298 ms |
96848 KB |
Output is correct |
66 |
Correct |
299 ms |
96928 KB |
Output is correct |
67 |
Correct |
299 ms |
96948 KB |
Output is correct |
68 |
Correct |
340 ms |
96852 KB |
Output is correct |
69 |
Correct |
303 ms |
96956 KB |
Output is correct |
70 |
Correct |
309 ms |
96988 KB |
Output is correct |
71 |
Correct |
324 ms |
97092 KB |
Output is correct |
72 |
Correct |
303 ms |
97008 KB |
Output is correct |
73 |
Correct |
307 ms |
97148 KB |
Output is correct |
74 |
Correct |
305 ms |
97108 KB |
Output is correct |
75 |
Correct |
304 ms |
97108 KB |
Output is correct |
76 |
Correct |
315 ms |
97080 KB |
Output is correct |
77 |
Correct |
277 ms |
97104 KB |
Output is correct |
78 |
Correct |
283 ms |
97068 KB |
Output is correct |
79 |
Correct |
280 ms |
97204 KB |
Output is correct |
80 |
Correct |
297 ms |
97104 KB |
Output is correct |