Submission #1114341

# Submission time Handle Problem Language Result Execution time Memory
1114341 2024-11-18T15:47:29 Z SalihSahin Netrpeljivost (COI23_netrpeljivost) C++14
100 / 100
443 ms 107112 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
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);
 
	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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 2 ms 6480 KB Output is correct
4 Correct 2 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 1 ms 6480 KB Output is correct
7 Correct 2 ms 6480 KB Output is correct
8 Correct 1 ms 6480 KB Output is correct
9 Correct 2 ms 6480 KB Output is correct
10 Correct 2 ms 6648 KB Output is correct
11 Correct 2 ms 6480 KB Output is correct
12 Correct 2 ms 6480 KB Output is correct
13 Correct 1 ms 6480 KB Output is correct
14 Correct 1 ms 6480 KB Output is correct
15 Correct 2 ms 6480 KB Output is correct
16 Correct 3 ms 6480 KB Output is correct
17 Correct 2 ms 6480 KB Output is correct
18 Correct 2 ms 6480 KB Output is correct
19 Correct 1 ms 6480 KB Output is correct
20 Correct 2 ms 6616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 2 ms 6480 KB Output is correct
4 Correct 2 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 1 ms 6480 KB Output is correct
7 Correct 2 ms 6480 KB Output is correct
8 Correct 1 ms 6480 KB Output is correct
9 Correct 2 ms 6480 KB Output is correct
10 Correct 2 ms 6648 KB Output is correct
11 Correct 2 ms 6480 KB Output is correct
12 Correct 2 ms 6480 KB Output is correct
13 Correct 1 ms 6480 KB Output is correct
14 Correct 1 ms 6480 KB Output is correct
15 Correct 2 ms 6480 KB Output is correct
16 Correct 3 ms 6480 KB Output is correct
17 Correct 2 ms 6480 KB Output is correct
18 Correct 2 ms 6480 KB Output is correct
19 Correct 1 ms 6480 KB Output is correct
20 Correct 2 ms 6616 KB Output is correct
21 Correct 3 ms 6736 KB Output is correct
22 Correct 3 ms 6900 KB Output is correct
23 Correct 5 ms 6736 KB Output is correct
24 Correct 2 ms 6480 KB Output is correct
25 Correct 2 ms 6680 KB Output is correct
26 Correct 3 ms 6736 KB Output is correct
27 Correct 3 ms 6736 KB Output is correct
28 Correct 3 ms 6736 KB Output is correct
29 Correct 3 ms 6736 KB Output is correct
30 Correct 3 ms 6736 KB Output is correct
31 Correct 3 ms 6736 KB Output is correct
32 Correct 3 ms 6956 KB Output is correct
33 Correct 4 ms 6736 KB Output is correct
34 Correct 3 ms 6736 KB Output is correct
35 Correct 3 ms 6736 KB Output is correct
36 Correct 4 ms 6736 KB Output is correct
37 Correct 3 ms 6736 KB Output is correct
38 Correct 3 ms 6736 KB Output is correct
39 Correct 3 ms 6780 KB Output is correct
40 Correct 3 ms 6904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 2 ms 6480 KB Output is correct
4 Correct 2 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 1 ms 6480 KB Output is correct
7 Correct 2 ms 6480 KB Output is correct
8 Correct 1 ms 6480 KB Output is correct
9 Correct 2 ms 6480 KB Output is correct
10 Correct 2 ms 6648 KB Output is correct
11 Correct 2 ms 6480 KB Output is correct
12 Correct 2 ms 6480 KB Output is correct
13 Correct 1 ms 6480 KB Output is correct
14 Correct 1 ms 6480 KB Output is correct
15 Correct 2 ms 6480 KB Output is correct
16 Correct 3 ms 6480 KB Output is correct
17 Correct 2 ms 6480 KB Output is correct
18 Correct 2 ms 6480 KB Output is correct
19 Correct 1 ms 6480 KB Output is correct
20 Correct 2 ms 6616 KB Output is correct
21 Correct 3 ms 6736 KB Output is correct
22 Correct 3 ms 6900 KB Output is correct
23 Correct 5 ms 6736 KB Output is correct
24 Correct 2 ms 6480 KB Output is correct
25 Correct 2 ms 6680 KB Output is correct
26 Correct 3 ms 6736 KB Output is correct
27 Correct 3 ms 6736 KB Output is correct
28 Correct 3 ms 6736 KB Output is correct
29 Correct 3 ms 6736 KB Output is correct
30 Correct 3 ms 6736 KB Output is correct
31 Correct 3 ms 6736 KB Output is correct
32 Correct 3 ms 6956 KB Output is correct
33 Correct 4 ms 6736 KB Output is correct
34 Correct 3 ms 6736 KB Output is correct
35 Correct 3 ms 6736 KB Output is correct
36 Correct 4 ms 6736 KB Output is correct
37 Correct 3 ms 6736 KB Output is correct
38 Correct 3 ms 6736 KB Output is correct
39 Correct 3 ms 6780 KB Output is correct
40 Correct 3 ms 6904 KB Output is correct
41 Correct 25 ms 19392 KB Output is correct
42 Correct 27 ms 19392 KB Output is correct
43 Correct 26 ms 20416 KB Output is correct
44 Correct 22 ms 21472 KB Output is correct
45 Correct 27 ms 20296 KB Output is correct
46 Correct 35 ms 20280 KB Output is correct
47 Correct 41 ms 19360 KB Output is correct
48 Correct 23 ms 18092 KB Output is correct
49 Correct 24 ms 17232 KB Output is correct
50 Correct 24 ms 18000 KB Output is correct
51 Correct 23 ms 20344 KB Output is correct
52 Correct 23 ms 20296 KB Output is correct
53 Correct 24 ms 17232 KB Output is correct
54 Correct 23 ms 19308 KB Output is correct
55 Correct 25 ms 17232 KB Output is correct
56 Correct 24 ms 17144 KB Output is correct
57 Correct 22 ms 20304 KB Output is correct
58 Correct 28 ms 19276 KB Output is correct
59 Correct 24 ms 17224 KB Output is correct
60 Correct 26 ms 17384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6480 KB Output is correct
2 Correct 1 ms 6480 KB Output is correct
3 Correct 2 ms 6480 KB Output is correct
4 Correct 2 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 1 ms 6480 KB Output is correct
7 Correct 2 ms 6480 KB Output is correct
8 Correct 1 ms 6480 KB Output is correct
9 Correct 2 ms 6480 KB Output is correct
10 Correct 2 ms 6648 KB Output is correct
11 Correct 2 ms 6480 KB Output is correct
12 Correct 2 ms 6480 KB Output is correct
13 Correct 1 ms 6480 KB Output is correct
14 Correct 1 ms 6480 KB Output is correct
15 Correct 2 ms 6480 KB Output is correct
16 Correct 3 ms 6480 KB Output is correct
17 Correct 2 ms 6480 KB Output is correct
18 Correct 2 ms 6480 KB Output is correct
19 Correct 1 ms 6480 KB Output is correct
20 Correct 2 ms 6616 KB Output is correct
21 Correct 3 ms 6736 KB Output is correct
22 Correct 3 ms 6900 KB Output is correct
23 Correct 5 ms 6736 KB Output is correct
24 Correct 2 ms 6480 KB Output is correct
25 Correct 2 ms 6680 KB Output is correct
26 Correct 3 ms 6736 KB Output is correct
27 Correct 3 ms 6736 KB Output is correct
28 Correct 3 ms 6736 KB Output is correct
29 Correct 3 ms 6736 KB Output is correct
30 Correct 3 ms 6736 KB Output is correct
31 Correct 3 ms 6736 KB Output is correct
32 Correct 3 ms 6956 KB Output is correct
33 Correct 4 ms 6736 KB Output is correct
34 Correct 3 ms 6736 KB Output is correct
35 Correct 3 ms 6736 KB Output is correct
36 Correct 4 ms 6736 KB Output is correct
37 Correct 3 ms 6736 KB Output is correct
38 Correct 3 ms 6736 KB Output is correct
39 Correct 3 ms 6780 KB Output is correct
40 Correct 3 ms 6904 KB Output is correct
41 Correct 25 ms 19392 KB Output is correct
42 Correct 27 ms 19392 KB Output is correct
43 Correct 26 ms 20416 KB Output is correct
44 Correct 22 ms 21472 KB Output is correct
45 Correct 27 ms 20296 KB Output is correct
46 Correct 35 ms 20280 KB Output is correct
47 Correct 41 ms 19360 KB Output is correct
48 Correct 23 ms 18092 KB Output is correct
49 Correct 24 ms 17232 KB Output is correct
50 Correct 24 ms 18000 KB Output is correct
51 Correct 23 ms 20344 KB Output is correct
52 Correct 23 ms 20296 KB Output is correct
53 Correct 24 ms 17232 KB Output is correct
54 Correct 23 ms 19308 KB Output is correct
55 Correct 25 ms 17232 KB Output is correct
56 Correct 24 ms 17144 KB Output is correct
57 Correct 22 ms 20304 KB Output is correct
58 Correct 28 ms 19276 KB Output is correct
59 Correct 24 ms 17224 KB Output is correct
60 Correct 26 ms 17384 KB Output is correct
61 Correct 374 ms 106288 KB Output is correct
62 Correct 419 ms 106436 KB Output is correct
63 Correct 398 ms 106464 KB Output is correct
64 Correct 391 ms 106384 KB Output is correct
65 Correct 405 ms 106312 KB Output is correct
66 Correct 433 ms 106432 KB Output is correct
67 Correct 391 ms 106608 KB Output is correct
68 Correct 407 ms 106312 KB Output is correct
69 Correct 412 ms 106312 KB Output is correct
70 Correct 386 ms 106312 KB Output is correct
71 Correct 404 ms 107080 KB Output is correct
72 Correct 377 ms 107080 KB Output is correct
73 Correct 397 ms 107112 KB Output is correct
74 Correct 443 ms 106928 KB Output is correct
75 Correct 402 ms 107080 KB Output is correct
76 Correct 364 ms 106968 KB Output is correct
77 Correct 389 ms 106972 KB Output is correct
78 Correct 372 ms 107080 KB Output is correct
79 Correct 414 ms 107108 KB Output is correct
80 Correct 388 ms 107080 KB Output is correct