Submission #114590

# Submission time Handle Problem Language Result Execution time Memory
114590 2019-06-02T00:36:54 Z wilwxk Roller Coaster Railroad (IOI16_railroad) C++11
34 / 100
369 ms 335136 KB
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const int MAXN=20;
const ll INF=1e18;
ll dist[MAXN][MAXN];
ll dp[MAXN][(1<<MAXN)];
int n;
 
ll fazdp(int cur, int mask) {
	if(dp[cur][mask]!=-1) return dp[cur][mask];
	dp[cur][mask]=INF;
	for(int viz=0; viz<n; viz++) {
		if(viz==cur) continue;
		if((mask&(1<<viz))==0) continue;
		ll val=fazdp(viz, mask^(1<<cur))+dist[viz][cur];
		dp[cur][mask]=min(dp[cur][mask], val);
	}
	// printf("%d %d >> %lld\n", cur, mask, dp[cur][mask]);
	return dp[cur][mask];
}
 
ll plan_roller_coaster(vector<int> s, vector<int> t) {
	n = (int) s.size();
 
	memset(dp, -1, sizeof(dp));
	for(int i=0; i<n; i++) dp[i][(1<<i)]=0;
 
	for(int i=0; i<n; i++) {
		for(int j=0; j<n; j++) {
			dist[i][j]= (t[i]<=s[j]) ? 0 : t[i]-s[j];
			if(i==j) dist[i][j]=0;
			// printf("d %d %d > %lld\n", i, j, dist[i][j]);
		}
	}
 
	ll respf=INF;
	for(int i=0; i<n; i++) respf=min(respf, fazdp(i, (1<<n)-1));
 
	return respf;
}
# Verdict Execution time Memory Grader output
1 Correct 120 ms 164568 KB n = 2
2 Correct 120 ms 164472 KB n = 2
3 Correct 120 ms 164600 KB n = 2
4 Correct 118 ms 164472 KB n = 2
5 Correct 118 ms 164472 KB n = 2
6 Correct 120 ms 164480 KB n = 2
7 Correct 118 ms 164472 KB n = 3
8 Correct 122 ms 164424 KB n = 3
9 Correct 121 ms 164452 KB n = 3
10 Correct 123 ms 164484 KB n = 8
11 Correct 132 ms 164412 KB n = 8
12 Correct 124 ms 164472 KB n = 8
13 Correct 124 ms 164472 KB n = 8
14 Correct 117 ms 164472 KB n = 8
15 Correct 123 ms 164504 KB n = 8
16 Correct 138 ms 164460 KB n = 8
17 Correct 126 ms 164432 KB n = 8
18 Correct 124 ms 164472 KB n = 8
19 Correct 124 ms 164472 KB n = 3
20 Correct 118 ms 164600 KB n = 7
21 Correct 121 ms 164476 KB n = 8
22 Correct 118 ms 164600 KB n = 8
23 Correct 119 ms 164444 KB n = 8
24 Correct 115 ms 164472 KB n = 8
25 Correct 119 ms 164472 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 120 ms 164568 KB n = 2
2 Correct 120 ms 164472 KB n = 2
3 Correct 120 ms 164600 KB n = 2
4 Correct 118 ms 164472 KB n = 2
5 Correct 118 ms 164472 KB n = 2
6 Correct 120 ms 164480 KB n = 2
7 Correct 118 ms 164472 KB n = 3
8 Correct 122 ms 164424 KB n = 3
9 Correct 121 ms 164452 KB n = 3
10 Correct 123 ms 164484 KB n = 8
11 Correct 132 ms 164412 KB n = 8
12 Correct 124 ms 164472 KB n = 8
13 Correct 124 ms 164472 KB n = 8
14 Correct 117 ms 164472 KB n = 8
15 Correct 123 ms 164504 KB n = 8
16 Correct 138 ms 164460 KB n = 8
17 Correct 126 ms 164432 KB n = 8
18 Correct 124 ms 164472 KB n = 8
19 Correct 124 ms 164472 KB n = 3
20 Correct 118 ms 164600 KB n = 7
21 Correct 121 ms 164476 KB n = 8
22 Correct 118 ms 164600 KB n = 8
23 Correct 119 ms 164444 KB n = 8
24 Correct 115 ms 164472 KB n = 8
25 Correct 119 ms 164472 KB n = 8
26 Correct 119 ms 164440 KB n = 8
27 Correct 120 ms 164476 KB n = 8
28 Correct 121 ms 164456 KB n = 8
29 Correct 189 ms 164604 KB n = 16
30 Correct 191 ms 164556 KB n = 16
31 Correct 174 ms 164472 KB n = 16
32 Correct 183 ms 164444 KB n = 16
33 Correct 174 ms 164492 KB n = 16
34 Correct 177 ms 164600 KB n = 16
35 Correct 173 ms 164472 KB n = 16
36 Correct 140 ms 164432 KB n = 15
37 Correct 127 ms 164472 KB n = 8
38 Correct 188 ms 164508 KB n = 16
39 Correct 169 ms 164472 KB n = 16
40 Correct 120 ms 164524 KB n = 9
41 Correct 189 ms 164576 KB n = 16
42 Correct 187 ms 164472 KB n = 16
43 Correct 174 ms 164572 KB n = 16
44 Correct 148 ms 164472 KB n = 9
45 Correct 146 ms 164448 KB n = 15
46 Correct 188 ms 164520 KB n = 16
47 Correct 202 ms 164472 KB n = 16
48 Correct 189 ms 164604 KB n = 16
# Verdict Execution time Memory Grader output
1 Runtime error 369 ms 335136 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 120 ms 164568 KB n = 2
2 Correct 120 ms 164472 KB n = 2
3 Correct 120 ms 164600 KB n = 2
4 Correct 118 ms 164472 KB n = 2
5 Correct 118 ms 164472 KB n = 2
6 Correct 120 ms 164480 KB n = 2
7 Correct 118 ms 164472 KB n = 3
8 Correct 122 ms 164424 KB n = 3
9 Correct 121 ms 164452 KB n = 3
10 Correct 123 ms 164484 KB n = 8
11 Correct 132 ms 164412 KB n = 8
12 Correct 124 ms 164472 KB n = 8
13 Correct 124 ms 164472 KB n = 8
14 Correct 117 ms 164472 KB n = 8
15 Correct 123 ms 164504 KB n = 8
16 Correct 138 ms 164460 KB n = 8
17 Correct 126 ms 164432 KB n = 8
18 Correct 124 ms 164472 KB n = 8
19 Correct 124 ms 164472 KB n = 3
20 Correct 118 ms 164600 KB n = 7
21 Correct 121 ms 164476 KB n = 8
22 Correct 118 ms 164600 KB n = 8
23 Correct 119 ms 164444 KB n = 8
24 Correct 115 ms 164472 KB n = 8
25 Correct 119 ms 164472 KB n = 8
26 Correct 119 ms 164440 KB n = 8
27 Correct 120 ms 164476 KB n = 8
28 Correct 121 ms 164456 KB n = 8
29 Correct 189 ms 164604 KB n = 16
30 Correct 191 ms 164556 KB n = 16
31 Correct 174 ms 164472 KB n = 16
32 Correct 183 ms 164444 KB n = 16
33 Correct 174 ms 164492 KB n = 16
34 Correct 177 ms 164600 KB n = 16
35 Correct 173 ms 164472 KB n = 16
36 Correct 140 ms 164432 KB n = 15
37 Correct 127 ms 164472 KB n = 8
38 Correct 188 ms 164508 KB n = 16
39 Correct 169 ms 164472 KB n = 16
40 Correct 120 ms 164524 KB n = 9
41 Correct 189 ms 164576 KB n = 16
42 Correct 187 ms 164472 KB n = 16
43 Correct 174 ms 164572 KB n = 16
44 Correct 148 ms 164472 KB n = 9
45 Correct 146 ms 164448 KB n = 15
46 Correct 188 ms 164520 KB n = 16
47 Correct 202 ms 164472 KB n = 16
48 Correct 189 ms 164604 KB n = 16
49 Runtime error 369 ms 335136 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Halted 0 ms 0 KB -