Submission #57833

# Submission time Handle Problem Language Result Execution time Memory
57833 2018-07-16T09:50:53 Z robert Roller Coaster Railroad (IOI16_railroad) C++14
34 / 100
163 ms 25172 KB
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

vector<int> s, t;

long long m[20][100100];

long long solve(long long p, long long sel){
	if(sel==((1<<(s.size()-1))-1))
		return 0;
	if(m[p][sel]!=-1)
		return m[p][sel];
	long long ret = 1e15;
	for(long long x=0ll; x<s.size()-1; x++){
		if(((1ll<<x)&sel)==0ll){
			//not selected
			ret = min(ret, solve(x, sel|(1<<x))+((s[x]<t[p])?(t[p]-s[x]):0ll));
		}
	}
	return m[p][sel] = ret;
}

long long plan_roller_coaster(vector<int> s_c, vector<int> t_c){
	s = s_c;
	t = t_c;
	s.push_back(1);
	t.push_back(1);
	memset(m, -1, sizeof(m));
	if(s_c.size()>100)
		return 0;
	return solve(t.size()-1, 0);
}
/*
int main(){
	vector<int> s_c = {1, 4, 5, 6}, t_c = {7, 3, 8, 6};
	cout << plan_roller_coaster(s_c, t_c) << endl;
}*/

Compilation message

railroad.cpp: In function 'long long int solve(long long int, long long int)':
railroad.cpp:17:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(long long x=0ll; x<s.size()-1; x++){
                       ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 14 ms 15992 KB n = 2
2 Correct 13 ms 16100 KB n = 2
3 Correct 13 ms 16152 KB n = 2
4 Correct 14 ms 16152 KB n = 2
5 Correct 17 ms 16152 KB n = 2
6 Correct 17 ms 16184 KB n = 2
7 Correct 14 ms 16184 KB n = 3
8 Correct 15 ms 16208 KB n = 3
9 Correct 17 ms 16208 KB n = 3
10 Correct 15 ms 16208 KB n = 8
11 Correct 16 ms 16208 KB n = 8
12 Correct 15 ms 16208 KB n = 8
13 Correct 15 ms 16236 KB n = 8
14 Correct 16 ms 16236 KB n = 8
15 Correct 15 ms 16236 KB n = 8
16 Correct 14 ms 16236 KB n = 8
17 Correct 15 ms 16236 KB n = 8
18 Correct 13 ms 16236 KB n = 8
19 Correct 13 ms 16236 KB n = 3
20 Correct 15 ms 16236 KB n = 7
21 Correct 14 ms 16236 KB n = 8
22 Correct 14 ms 16320 KB n = 8
23 Correct 13 ms 16320 KB n = 8
24 Correct 13 ms 16320 KB n = 8
25 Correct 14 ms 16320 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 14 ms 15992 KB n = 2
2 Correct 13 ms 16100 KB n = 2
3 Correct 13 ms 16152 KB n = 2
4 Correct 14 ms 16152 KB n = 2
5 Correct 17 ms 16152 KB n = 2
6 Correct 17 ms 16184 KB n = 2
7 Correct 14 ms 16184 KB n = 3
8 Correct 15 ms 16208 KB n = 3
9 Correct 17 ms 16208 KB n = 3
10 Correct 15 ms 16208 KB n = 8
11 Correct 16 ms 16208 KB n = 8
12 Correct 15 ms 16208 KB n = 8
13 Correct 15 ms 16236 KB n = 8
14 Correct 16 ms 16236 KB n = 8
15 Correct 15 ms 16236 KB n = 8
16 Correct 14 ms 16236 KB n = 8
17 Correct 15 ms 16236 KB n = 8
18 Correct 13 ms 16236 KB n = 8
19 Correct 13 ms 16236 KB n = 3
20 Correct 15 ms 16236 KB n = 7
21 Correct 14 ms 16236 KB n = 8
22 Correct 14 ms 16320 KB n = 8
23 Correct 13 ms 16320 KB n = 8
24 Correct 13 ms 16320 KB n = 8
25 Correct 14 ms 16320 KB n = 8
26 Correct 16 ms 16320 KB n = 8
27 Correct 17 ms 16380 KB n = 8
28 Correct 16 ms 16380 KB n = 8
29 Correct 117 ms 16380 KB n = 16
30 Correct 113 ms 16380 KB n = 16
31 Correct 163 ms 16380 KB n = 16
32 Correct 158 ms 16380 KB n = 16
33 Correct 99 ms 16380 KB n = 16
34 Correct 114 ms 16384 KB n = 16
35 Correct 98 ms 16384 KB n = 16
36 Correct 50 ms 16384 KB n = 15
37 Correct 12 ms 16384 KB n = 8
38 Correct 99 ms 16384 KB n = 16
39 Correct 128 ms 16384 KB n = 16
40 Correct 14 ms 16384 KB n = 9
41 Correct 158 ms 16420 KB n = 16
42 Correct 141 ms 16420 KB n = 16
43 Correct 153 ms 16420 KB n = 16
44 Correct 17 ms 16420 KB n = 9
45 Correct 50 ms 16420 KB n = 15
46 Correct 130 ms 16420 KB n = 16
47 Correct 153 ms 16420 KB n = 16
48 Correct 132 ms 16420 KB n = 16
# Verdict Execution time Memory Grader output
1 Correct 94 ms 21212 KB n = 199999
2 Incorrect 96 ms 25172 KB answer is not correct: 0 instead of 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 15992 KB n = 2
2 Correct 13 ms 16100 KB n = 2
3 Correct 13 ms 16152 KB n = 2
4 Correct 14 ms 16152 KB n = 2
5 Correct 17 ms 16152 KB n = 2
6 Correct 17 ms 16184 KB n = 2
7 Correct 14 ms 16184 KB n = 3
8 Correct 15 ms 16208 KB n = 3
9 Correct 17 ms 16208 KB n = 3
10 Correct 15 ms 16208 KB n = 8
11 Correct 16 ms 16208 KB n = 8
12 Correct 15 ms 16208 KB n = 8
13 Correct 15 ms 16236 KB n = 8
14 Correct 16 ms 16236 KB n = 8
15 Correct 15 ms 16236 KB n = 8
16 Correct 14 ms 16236 KB n = 8
17 Correct 15 ms 16236 KB n = 8
18 Correct 13 ms 16236 KB n = 8
19 Correct 13 ms 16236 KB n = 3
20 Correct 15 ms 16236 KB n = 7
21 Correct 14 ms 16236 KB n = 8
22 Correct 14 ms 16320 KB n = 8
23 Correct 13 ms 16320 KB n = 8
24 Correct 13 ms 16320 KB n = 8
25 Correct 14 ms 16320 KB n = 8
26 Correct 16 ms 16320 KB n = 8
27 Correct 17 ms 16380 KB n = 8
28 Correct 16 ms 16380 KB n = 8
29 Correct 117 ms 16380 KB n = 16
30 Correct 113 ms 16380 KB n = 16
31 Correct 163 ms 16380 KB n = 16
32 Correct 158 ms 16380 KB n = 16
33 Correct 99 ms 16380 KB n = 16
34 Correct 114 ms 16384 KB n = 16
35 Correct 98 ms 16384 KB n = 16
36 Correct 50 ms 16384 KB n = 15
37 Correct 12 ms 16384 KB n = 8
38 Correct 99 ms 16384 KB n = 16
39 Correct 128 ms 16384 KB n = 16
40 Correct 14 ms 16384 KB n = 9
41 Correct 158 ms 16420 KB n = 16
42 Correct 141 ms 16420 KB n = 16
43 Correct 153 ms 16420 KB n = 16
44 Correct 17 ms 16420 KB n = 9
45 Correct 50 ms 16420 KB n = 15
46 Correct 130 ms 16420 KB n = 16
47 Correct 153 ms 16420 KB n = 16
48 Correct 132 ms 16420 KB n = 16
49 Correct 94 ms 21212 KB n = 199999
50 Incorrect 96 ms 25172 KB answer is not correct: 0 instead of 1
51 Halted 0 ms 0 KB -