# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029269 | 2024-07-20T14:35:36 Z | berr | Netrpeljivost (COI23_netrpeljivost) | C++17 | 402 ms | 107272 KB |
#include <bits/stdc++.h> using namespace std; #define int long long void f(){ #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif } int dp[1<<11][(1<<11)+1]; int d[(1<<11)+1][(1<<11)+1]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); //f(); int n; cin >> n; for(int i=0; i<=n; i++){ for(int j=0; j<n; j++){ dp[j][i]=1e18; } dp[0][i]=0; } for(int i=0; i<n; i++){ for(int l=0; l<n; l++) cin >> d[i][l]; } for(int i=1; i<n; i++){ int c=0, val=i; int f=0; for(int h=0; h<11; h++){ if(val&(1<<h)){ c=h; break; } } for(int h=c; h<=11; h++){ f+=(1<<h); } for(int g=0; g<n; g++){ if(g&(1<<c)){ int h = g^(1<<c); h&=f; for(int l=0; l<(1<<c); l++){ dp[i][h+l]=min(dp[i][h+l], dp[i-1][g]+d[g][h+l]); } } else{ int h = g^(1<<c); h&=f; for(int l=0; l<(1<<c); l++){ dp[i][h+l]=min(dp[i][h+l], dp[i-1][g]+d[g][h+l]); } } } } int mi=1e18; for(int l=0; l<n; l++) mi=min(mi, dp[n-1][l]); cout<<mi; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 604 KB | Output is correct |
4 | Correct | 0 ms | 604 KB | Output is correct |
5 | Correct | 0 ms | 604 KB | Output is correct |
6 | Correct | 0 ms | 600 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 604 KB | Output is correct |
11 | Correct | 0 ms | 604 KB | Output is correct |
12 | Correct | 1 ms | 604 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 604 KB | Output is correct |
15 | Correct | 1 ms | 604 KB | Output is correct |
16 | Correct | 1 ms | 604 KB | Output is correct |
17 | Correct | 1 ms | 604 KB | Output is correct |
18 | Correct | 1 ms | 604 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 604 KB | Output is correct |
4 | Correct | 0 ms | 604 KB | Output is correct |
5 | Correct | 0 ms | 604 KB | Output is correct |
6 | Correct | 0 ms | 600 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 604 KB | Output is correct |
11 | Correct | 0 ms | 604 KB | Output is correct |
12 | Correct | 1 ms | 604 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 604 KB | Output is correct |
15 | Correct | 1 ms | 604 KB | Output is correct |
16 | Correct | 1 ms | 604 KB | Output is correct |
17 | Correct | 1 ms | 604 KB | Output is correct |
18 | Correct | 1 ms | 604 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 468 KB | Output is correct |
21 | Correct | 2 ms | 1504 KB | Output is correct |
22 | Correct | 2 ms | 1624 KB | Output is correct |
23 | Correct | 3 ms | 1504 KB | Output is correct |
24 | Correct | 1 ms | 860 KB | Output is correct |
25 | Correct | 1 ms | 860 KB | Output is correct |
26 | Correct | 2 ms | 1628 KB | Output is correct |
27 | Correct | 2 ms | 1628 KB | Output is correct |
28 | Correct | 2 ms | 1412 KB | Output is correct |
29 | Correct | 2 ms | 1628 KB | Output is correct |
30 | Correct | 3 ms | 1628 KB | Output is correct |
31 | Correct | 2 ms | 1628 KB | Output is correct |
32 | Correct | 3 ms | 1628 KB | Output is correct |
33 | Correct | 1 ms | 1628 KB | Output is correct |
34 | Correct | 2 ms | 1628 KB | Output is correct |
35 | Correct | 2 ms | 1628 KB | Output is correct |
36 | Correct | 2 ms | 1628 KB | Output is correct |
37 | Correct | 3 ms | 1628 KB | Output is correct |
38 | Correct | 2 ms | 1660 KB | Output is correct |
39 | Correct | 2 ms | 1516 KB | Output is correct |
40 | Correct | 2 ms | 1628 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 604 KB | Output is correct |
4 | Correct | 0 ms | 604 KB | Output is correct |
5 | Correct | 0 ms | 604 KB | Output is correct |
6 | Correct | 0 ms | 600 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 604 KB | Output is correct |
11 | Correct | 0 ms | 604 KB | Output is correct |
12 | Correct | 1 ms | 604 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 604 KB | Output is correct |
15 | Correct | 1 ms | 604 KB | Output is correct |
16 | Correct | 1 ms | 604 KB | Output is correct |
17 | Correct | 1 ms | 604 KB | Output is correct |
18 | Correct | 1 ms | 604 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 468 KB | Output is correct |
21 | Correct | 2 ms | 1504 KB | Output is correct |
22 | Correct | 2 ms | 1624 KB | Output is correct |
23 | Correct | 3 ms | 1504 KB | Output is correct |
24 | Correct | 1 ms | 860 KB | Output is correct |
25 | Correct | 1 ms | 860 KB | Output is correct |
26 | Correct | 2 ms | 1628 KB | Output is correct |
27 | Correct | 2 ms | 1628 KB | Output is correct |
28 | Correct | 2 ms | 1412 KB | Output is correct |
29 | Correct | 2 ms | 1628 KB | Output is correct |
30 | Correct | 3 ms | 1628 KB | Output is correct |
31 | Correct | 2 ms | 1628 KB | Output is correct |
32 | Correct | 3 ms | 1628 KB | Output is correct |
33 | Correct | 1 ms | 1628 KB | Output is correct |
34 | Correct | 2 ms | 1628 KB | Output is correct |
35 | Correct | 2 ms | 1628 KB | Output is correct |
36 | Correct | 2 ms | 1628 KB | Output is correct |
37 | Correct | 3 ms | 1628 KB | Output is correct |
38 | Correct | 2 ms | 1660 KB | Output is correct |
39 | Correct | 2 ms | 1516 KB | Output is correct |
40 | Correct | 2 ms | 1628 KB | Output is correct |
41 | Correct | 20 ms | 11056 KB | Output is correct |
42 | Correct | 22 ms | 11068 KB | Output is correct |
43 | Correct | 21 ms | 11096 KB | Output is correct |
44 | Correct | 35 ms | 11088 KB | Output is correct |
45 | Correct | 24 ms | 11172 KB | Output is correct |
46 | Correct | 24 ms | 11100 KB | Output is correct |
47 | Correct | 22 ms | 11100 KB | Output is correct |
48 | Correct | 23 ms | 11052 KB | Output is correct |
49 | Correct | 39 ms | 11092 KB | Output is correct |
50 | Correct | 25 ms | 11092 KB | Output is correct |
51 | Correct | 34 ms | 11084 KB | Output is correct |
52 | Correct | 29 ms | 11084 KB | Output is correct |
53 | Correct | 31 ms | 11092 KB | Output is correct |
54 | Correct | 23 ms | 11096 KB | Output is correct |
55 | Correct | 22 ms | 11092 KB | Output is correct |
56 | Correct | 34 ms | 11092 KB | Output is correct |
57 | Correct | 22 ms | 11092 KB | Output is correct |
58 | Correct | 22 ms | 11112 KB | Output is correct |
59 | Correct | 27 ms | 11100 KB | Output is correct |
60 | Correct | 24 ms | 11016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 604 KB | Output is correct |
4 | Correct | 0 ms | 604 KB | Output is correct |
5 | Correct | 0 ms | 604 KB | Output is correct |
6 | Correct | 0 ms | 600 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 604 KB | Output is correct |
11 | Correct | 0 ms | 604 KB | Output is correct |
12 | Correct | 1 ms | 604 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 604 KB | Output is correct |
15 | Correct | 1 ms | 604 KB | Output is correct |
16 | Correct | 1 ms | 604 KB | Output is correct |
17 | Correct | 1 ms | 604 KB | Output is correct |
18 | Correct | 1 ms | 604 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 468 KB | Output is correct |
21 | Correct | 2 ms | 1504 KB | Output is correct |
22 | Correct | 2 ms | 1624 KB | Output is correct |
23 | Correct | 3 ms | 1504 KB | Output is correct |
24 | Correct | 1 ms | 860 KB | Output is correct |
25 | Correct | 1 ms | 860 KB | Output is correct |
26 | Correct | 2 ms | 1628 KB | Output is correct |
27 | Correct | 2 ms | 1628 KB | Output is correct |
28 | Correct | 2 ms | 1412 KB | Output is correct |
29 | Correct | 2 ms | 1628 KB | Output is correct |
30 | Correct | 3 ms | 1628 KB | Output is correct |
31 | Correct | 2 ms | 1628 KB | Output is correct |
32 | Correct | 3 ms | 1628 KB | Output is correct |
33 | Correct | 1 ms | 1628 KB | Output is correct |
34 | Correct | 2 ms | 1628 KB | Output is correct |
35 | Correct | 2 ms | 1628 KB | Output is correct |
36 | Correct | 2 ms | 1628 KB | Output is correct |
37 | Correct | 3 ms | 1628 KB | Output is correct |
38 | Correct | 2 ms | 1660 KB | Output is correct |
39 | Correct | 2 ms | 1516 KB | Output is correct |
40 | Correct | 2 ms | 1628 KB | Output is correct |
41 | Correct | 20 ms | 11056 KB | Output is correct |
42 | Correct | 22 ms | 11068 KB | Output is correct |
43 | Correct | 21 ms | 11096 KB | Output is correct |
44 | Correct | 35 ms | 11088 KB | Output is correct |
45 | Correct | 24 ms | 11172 KB | Output is correct |
46 | Correct | 24 ms | 11100 KB | Output is correct |
47 | Correct | 22 ms | 11100 KB | Output is correct |
48 | Correct | 23 ms | 11052 KB | Output is correct |
49 | Correct | 39 ms | 11092 KB | Output is correct |
50 | Correct | 25 ms | 11092 KB | Output is correct |
51 | Correct | 34 ms | 11084 KB | Output is correct |
52 | Correct | 29 ms | 11084 KB | Output is correct |
53 | Correct | 31 ms | 11092 KB | Output is correct |
54 | Correct | 23 ms | 11096 KB | Output is correct |
55 | Correct | 22 ms | 11092 KB | Output is correct |
56 | Correct | 34 ms | 11092 KB | Output is correct |
57 | Correct | 22 ms | 11092 KB | Output is correct |
58 | Correct | 22 ms | 11112 KB | Output is correct |
59 | Correct | 27 ms | 11100 KB | Output is correct |
60 | Correct | 24 ms | 11016 KB | Output is correct |
61 | Correct | 341 ms | 106320 KB | Output is correct |
62 | Correct | 328 ms | 106276 KB | Output is correct |
63 | Correct | 360 ms | 106280 KB | Output is correct |
64 | Correct | 335 ms | 106324 KB | Output is correct |
65 | Correct | 317 ms | 106312 KB | Output is correct |
66 | Correct | 325 ms | 106320 KB | Output is correct |
67 | Correct | 320 ms | 106324 KB | Output is correct |
68 | Correct | 340 ms | 106448 KB | Output is correct |
69 | Correct | 333 ms | 106256 KB | Output is correct |
70 | Correct | 317 ms | 106244 KB | Output is correct |
71 | Correct | 338 ms | 106924 KB | Output is correct |
72 | Correct | 316 ms | 107088 KB | Output is correct |
73 | Correct | 310 ms | 106900 KB | Output is correct |
74 | Correct | 340 ms | 107272 KB | Output is correct |
75 | Correct | 328 ms | 106844 KB | Output is correct |
76 | Correct | 341 ms | 107056 KB | Output is correct |
77 | Correct | 402 ms | 107092 KB | Output is correct |
78 | Correct | 346 ms | 107140 KB | Output is correct |
79 | Correct | 326 ms | 106832 KB | Output is correct |
80 | Correct | 343 ms | 107020 KB | Output is correct |