Submission #69364

# Submission time Handle Problem Language Result Execution time Memory
69364 2018-08-20T16:14:20 Z hamzqq9 Roller Coaster Railroad (IOI16_railroad) C++14
34 / 100
149 ms 8764 KB
#include "railroad.h"
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 200000000000000000
#define MOD 1000000007
#define N 755
#define MAX 10000006
#define LOG 30
#define KOK 200
using namespace std;

ll full;
bool vis[16][pw(16)];
ll dp[16][pw(16)];
vector<ii> v[16];

ll S3(vector<int>&s, vector<int>& t) {

	return 0;

}

ll solve(int now,int mask) {

	if(vis[now][mask]) return dp[now][mask];

	if(mask==full) return 0;

	vis[now][mask]=1;

	ll& r=dp[now][mask];

	r=inf;

	for(int i=0;i<sz(v[now]);i++) {

		if(mask&pw(v[now][i].nd)) continue ;

		umin(r,solve(v[now][i].nd,mask|pw(v[now][i].nd))+v[now][i].st);

	}

	return r;

}

ll S12(vector<int>&s, vector<int>& t) {

	for(int i=0;i<sz(s);i++) {

		for(int j=0;j<sz(s);j++) {

			if(i==j) continue ;

			v[i].pb({max(0,t[i]-s[j]),j});

		}

	}

	full=pw(sz(s))-1;

	ll ans=inf;

	for(int i=0;i<sz(s);i++) {

		umin(ans,solve(i,pw(i)));

	}

	return ans;

}

long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
    
	if(sz(s)<=16) return S12(s,t);
	else return S3(s,t);

}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB n = 2
2 Correct 2 ms 452 KB n = 2
3 Correct 3 ms 452 KB n = 2
4 Correct 2 ms 452 KB n = 2
5 Correct 2 ms 452 KB n = 2
6 Correct 2 ms 520 KB n = 2
7 Correct 3 ms 576 KB n = 3
8 Correct 2 ms 576 KB n = 3
9 Correct 2 ms 576 KB n = 3
10 Correct 2 ms 576 KB n = 8
11 Correct 2 ms 576 KB n = 8
12 Correct 3 ms 576 KB n = 8
13 Correct 2 ms 576 KB n = 8
14 Correct 4 ms 668 KB n = 8
15 Correct 3 ms 668 KB n = 8
16 Correct 2 ms 668 KB n = 8
17 Correct 2 ms 668 KB n = 8
18 Correct 2 ms 668 KB n = 8
19 Correct 3 ms 668 KB n = 3
20 Correct 3 ms 668 KB n = 7
21 Correct 2 ms 668 KB n = 8
22 Correct 3 ms 668 KB n = 8
23 Correct 3 ms 668 KB n = 8
24 Correct 3 ms 668 KB n = 8
25 Correct 3 ms 684 KB n = 8
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB n = 2
2 Correct 2 ms 452 KB n = 2
3 Correct 3 ms 452 KB n = 2
4 Correct 2 ms 452 KB n = 2
5 Correct 2 ms 452 KB n = 2
6 Correct 2 ms 520 KB n = 2
7 Correct 3 ms 576 KB n = 3
8 Correct 2 ms 576 KB n = 3
9 Correct 2 ms 576 KB n = 3
10 Correct 2 ms 576 KB n = 8
11 Correct 2 ms 576 KB n = 8
12 Correct 3 ms 576 KB n = 8
13 Correct 2 ms 576 KB n = 8
14 Correct 4 ms 668 KB n = 8
15 Correct 3 ms 668 KB n = 8
16 Correct 2 ms 668 KB n = 8
17 Correct 2 ms 668 KB n = 8
18 Correct 2 ms 668 KB n = 8
19 Correct 3 ms 668 KB n = 3
20 Correct 3 ms 668 KB n = 7
21 Correct 2 ms 668 KB n = 8
22 Correct 3 ms 668 KB n = 8
23 Correct 3 ms 668 KB n = 8
24 Correct 3 ms 668 KB n = 8
25 Correct 3 ms 684 KB n = 8
26 Correct 2 ms 692 KB n = 8
27 Correct 2 ms 692 KB n = 8
28 Correct 2 ms 728 KB n = 8
29 Correct 97 ms 8764 KB n = 16
30 Correct 123 ms 8764 KB n = 16
31 Correct 95 ms 8764 KB n = 16
32 Correct 102 ms 8764 KB n = 16
33 Correct 99 ms 8764 KB n = 16
34 Correct 110 ms 8764 KB n = 16
35 Correct 149 ms 8764 KB n = 16
36 Correct 34 ms 8764 KB n = 15
37 Correct 3 ms 8764 KB n = 8
38 Correct 92 ms 8764 KB n = 16
39 Correct 106 ms 8764 KB n = 16
40 Correct 3 ms 8764 KB n = 9
41 Correct 96 ms 8764 KB n = 16
42 Correct 115 ms 8764 KB n = 16
43 Correct 107 ms 8764 KB n = 16
44 Correct 3 ms 8764 KB n = 9
45 Correct 38 ms 8764 KB n = 15
46 Correct 96 ms 8764 KB n = 16
47 Correct 105 ms 8764 KB n = 16
48 Correct 137 ms 8764 KB n = 16
# Verdict Execution time Memory Grader output
1 Correct 80 ms 8764 KB n = 199999
2 Incorrect 72 ms 8764 KB answer is not correct: 0 instead of 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB n = 2
2 Correct 2 ms 452 KB n = 2
3 Correct 3 ms 452 KB n = 2
4 Correct 2 ms 452 KB n = 2
5 Correct 2 ms 452 KB n = 2
6 Correct 2 ms 520 KB n = 2
7 Correct 3 ms 576 KB n = 3
8 Correct 2 ms 576 KB n = 3
9 Correct 2 ms 576 KB n = 3
10 Correct 2 ms 576 KB n = 8
11 Correct 2 ms 576 KB n = 8
12 Correct 3 ms 576 KB n = 8
13 Correct 2 ms 576 KB n = 8
14 Correct 4 ms 668 KB n = 8
15 Correct 3 ms 668 KB n = 8
16 Correct 2 ms 668 KB n = 8
17 Correct 2 ms 668 KB n = 8
18 Correct 2 ms 668 KB n = 8
19 Correct 3 ms 668 KB n = 3
20 Correct 3 ms 668 KB n = 7
21 Correct 2 ms 668 KB n = 8
22 Correct 3 ms 668 KB n = 8
23 Correct 3 ms 668 KB n = 8
24 Correct 3 ms 668 KB n = 8
25 Correct 3 ms 684 KB n = 8
26 Correct 2 ms 692 KB n = 8
27 Correct 2 ms 692 KB n = 8
28 Correct 2 ms 728 KB n = 8
29 Correct 97 ms 8764 KB n = 16
30 Correct 123 ms 8764 KB n = 16
31 Correct 95 ms 8764 KB n = 16
32 Correct 102 ms 8764 KB n = 16
33 Correct 99 ms 8764 KB n = 16
34 Correct 110 ms 8764 KB n = 16
35 Correct 149 ms 8764 KB n = 16
36 Correct 34 ms 8764 KB n = 15
37 Correct 3 ms 8764 KB n = 8
38 Correct 92 ms 8764 KB n = 16
39 Correct 106 ms 8764 KB n = 16
40 Correct 3 ms 8764 KB n = 9
41 Correct 96 ms 8764 KB n = 16
42 Correct 115 ms 8764 KB n = 16
43 Correct 107 ms 8764 KB n = 16
44 Correct 3 ms 8764 KB n = 9
45 Correct 38 ms 8764 KB n = 15
46 Correct 96 ms 8764 KB n = 16
47 Correct 105 ms 8764 KB n = 16
48 Correct 137 ms 8764 KB n = 16
49 Correct 80 ms 8764 KB n = 199999
50 Incorrect 72 ms 8764 KB answer is not correct: 0 instead of 1
51 Halted 0 ms 0 KB -