Submission #966019

# Submission time Handle Problem Language Result Execution time Memory
966019 2024-04-19T09:35:55 Z Darren0724 Fun Tour (APIO20_fun) C++17
47 / 100
115 ms 111820 KB
#include "fun.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
const int N=2000005;
int cntid=0;
const int INF=1e9;
vector<int> sz(N,1),pa(N),ans,dis(N);
priority_queue<pair<int,int>> pq[10];
vector<int> createFunTour(int n, int q) {
  	//int H = hoursRequired(0, N - 1);
  	//int A = attractionsBehind(0, N - 1);
	int c1=0;
	int need=(n+1)/2;
	int mn=INF;
	for(int i=1;i<n;i++){
		int t=attractionsBehind(0, i);
		if(t>=need&&t<mn){
			mn=t;
			c1=i;
		}
	}
	vector<int> r;

	vector<int> dis0(N,0);
	for(int i=0;i<n;i++){
		dis0[i]=hoursRequired(c1,i);
		if(dis0[i]==1){
			r.push_back(i);
		}
	}
	int rsz=r.size()-1;
	assert(rsz<=2);
	vector<vector<int>> dis(rsz,vector<int>(N));
	vector<int> vis(N);
	for(int i=0;i<rsz;i++){
		for(int j=0;j<n;j++){
			dis[i][j]=hoursRequired(r[i],j);
		}
	}
	for(int i=0;i<n;i++){
		if(i==c1)continue;
		int p=-1;
		for(int j=0;j<rsz;j++){
			if(dis[j][i]<dis0[i]){
				p=j;break;
			}
		}
		if(p==-1)p=rsz;
		pq[p].push({dis0[i],i});
	}
	cntid=r.size();
	int last=-1;
	for(int i=1;i<n;i++){
		pair<int,int> p={-1,-1};
		for(int j=0;j<cntid;j++){
			if(j==last||pq[j].size()==0)continue;
			p=max(p,make_pair(pq[j].top().first,j));
		}
		last=p.second;
		if(last==-1&&pq[last].size()==0)while(1){}
		auto [dis1,idx]=pq[last].top();
		pq[last].pop();
		ans.push_back(idx);
	}
	ans.push_back(c1);
	/*for(int j:ans){
		cout<<j<<' ';
	}
	cout<<endl;*/
  	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 55248 KB Output is correct
2 Correct 9 ms 39636 KB Output is correct
3 Correct 11 ms 47316 KB Output is correct
4 Correct 14 ms 47316 KB Output is correct
5 Correct 13 ms 55248 KB Output is correct
6 Correct 13 ms 55248 KB Output is correct
7 Correct 11 ms 47316 KB Output is correct
8 Correct 13 ms 55264 KB Output is correct
9 Correct 13 ms 55504 KB Output is correct
10 Correct 11 ms 47320 KB Output is correct
11 Correct 14 ms 55248 KB Output is correct
12 Correct 13 ms 55252 KB Output is correct
13 Correct 11 ms 47312 KB Output is correct
14 Correct 13 ms 55252 KB Output is correct
15 Correct 11 ms 47404 KB Output is correct
16 Correct 13 ms 55248 KB Output is correct
17 Correct 14 ms 55504 KB Output is correct
18 Correct 13 ms 55248 KB Output is correct
19 Correct 13 ms 55252 KB Output is correct
20 Correct 13 ms 47568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 55248 KB Output is correct
2 Correct 9 ms 39636 KB Output is correct
3 Correct 11 ms 47316 KB Output is correct
4 Correct 14 ms 47316 KB Output is correct
5 Correct 13 ms 55248 KB Output is correct
6 Correct 13 ms 55248 KB Output is correct
7 Correct 11 ms 47316 KB Output is correct
8 Correct 13 ms 55264 KB Output is correct
9 Correct 13 ms 55504 KB Output is correct
10 Correct 11 ms 47320 KB Output is correct
11 Correct 14 ms 55248 KB Output is correct
12 Correct 13 ms 55252 KB Output is correct
13 Correct 11 ms 47312 KB Output is correct
14 Correct 13 ms 55252 KB Output is correct
15 Correct 11 ms 47404 KB Output is correct
16 Correct 13 ms 55248 KB Output is correct
17 Correct 14 ms 55504 KB Output is correct
18 Correct 13 ms 55248 KB Output is correct
19 Correct 13 ms 55252 KB Output is correct
20 Correct 13 ms 47568 KB Output is correct
21 Correct 13 ms 55252 KB Output is correct
22 Correct 13 ms 55252 KB Output is correct
23 Correct 11 ms 47340 KB Output is correct
24 Correct 14 ms 55196 KB Output is correct
25 Correct 13 ms 55252 KB Output is correct
26 Correct 12 ms 55252 KB Output is correct
27 Correct 14 ms 55224 KB Output is correct
28 Correct 13 ms 55248 KB Output is correct
29 Correct 14 ms 55252 KB Output is correct
30 Correct 11 ms 47316 KB Output is correct
31 Correct 13 ms 55252 KB Output is correct
32 Correct 13 ms 55192 KB Output is correct
33 Correct 13 ms 55252 KB Output is correct
34 Correct 11 ms 47464 KB Output is correct
35 Correct 13 ms 55236 KB Output is correct
36 Correct 13 ms 55288 KB Output is correct
37 Correct 13 ms 55252 KB Output is correct
38 Correct 13 ms 55252 KB Output is correct
39 Correct 13 ms 55248 KB Output is correct
40 Correct 13 ms 55248 KB Output is correct
41 Correct 11 ms 47448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 39636 KB Output is correct
2 Correct 11 ms 47316 KB Output is correct
3 Correct 14 ms 47316 KB Output is correct
4 Correct 13 ms 55248 KB Output is correct
5 Correct 13 ms 55248 KB Output is correct
6 Correct 11 ms 47316 KB Output is correct
7 Correct 13 ms 55264 KB Output is correct
8 Correct 13 ms 55504 KB Output is correct
9 Correct 13 ms 55252 KB Output is correct
10 Correct 13 ms 55252 KB Output is correct
11 Correct 11 ms 47340 KB Output is correct
12 Correct 14 ms 55196 KB Output is correct
13 Correct 13 ms 55252 KB Output is correct
14 Correct 12 ms 55252 KB Output is correct
15 Correct 14 ms 55224 KB Output is correct
16 Correct 13 ms 55252 KB Output is correct
17 Correct 11 ms 47452 KB Output is correct
18 Correct 115 ms 70516 KB Output is correct
19 Correct 14 ms 55248 KB Output is correct
20 Correct 14 ms 55504 KB Output is correct
21 Correct 16 ms 55508 KB Output is correct
22 Correct 18 ms 56100 KB Output is correct
23 Correct 23 ms 57044 KB Output is correct
24 Correct 25 ms 57808 KB Output is correct
25 Correct 70 ms 63972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 39636 KB Output is correct
2 Correct 11 ms 47316 KB Output is correct
3 Correct 11 ms 47320 KB Output is correct
4 Correct 14 ms 55248 KB Output is correct
5 Correct 13 ms 55252 KB Output is correct
6 Correct 11 ms 47312 KB Output is correct
7 Correct 13 ms 55248 KB Output is correct
8 Correct 14 ms 55252 KB Output is correct
9 Correct 11 ms 47316 KB Output is correct
10 Correct 13 ms 55252 KB Output is correct
11 Correct 13 ms 55192 KB Output is correct
12 Correct 13 ms 55252 KB Output is correct
13 Runtime error 59 ms 111820 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 55248 KB Output is correct
2 Correct 9 ms 39636 KB Output is correct
3 Correct 11 ms 47316 KB Output is correct
4 Correct 14 ms 47316 KB Output is correct
5 Correct 13 ms 55248 KB Output is correct
6 Correct 13 ms 55248 KB Output is correct
7 Correct 11 ms 47316 KB Output is correct
8 Correct 13 ms 55264 KB Output is correct
9 Correct 13 ms 55504 KB Output is correct
10 Correct 11 ms 47320 KB Output is correct
11 Correct 14 ms 55248 KB Output is correct
12 Correct 13 ms 55252 KB Output is correct
13 Correct 11 ms 47312 KB Output is correct
14 Correct 13 ms 55252 KB Output is correct
15 Correct 11 ms 47404 KB Output is correct
16 Correct 13 ms 55248 KB Output is correct
17 Correct 14 ms 55504 KB Output is correct
18 Correct 13 ms 55248 KB Output is correct
19 Correct 13 ms 55252 KB Output is correct
20 Correct 13 ms 47568 KB Output is correct
21 Correct 13 ms 55252 KB Output is correct
22 Correct 13 ms 55252 KB Output is correct
23 Correct 11 ms 47340 KB Output is correct
24 Correct 14 ms 55196 KB Output is correct
25 Correct 13 ms 55252 KB Output is correct
26 Correct 12 ms 55252 KB Output is correct
27 Correct 14 ms 55224 KB Output is correct
28 Correct 13 ms 55248 KB Output is correct
29 Correct 14 ms 55252 KB Output is correct
30 Correct 11 ms 47316 KB Output is correct
31 Correct 13 ms 55252 KB Output is correct
32 Correct 13 ms 55192 KB Output is correct
33 Correct 13 ms 55252 KB Output is correct
34 Correct 11 ms 47464 KB Output is correct
35 Correct 13 ms 55236 KB Output is correct
36 Correct 13 ms 55288 KB Output is correct
37 Correct 13 ms 55252 KB Output is correct
38 Correct 13 ms 55252 KB Output is correct
39 Correct 13 ms 55248 KB Output is correct
40 Correct 13 ms 55248 KB Output is correct
41 Correct 11 ms 47448 KB Output is correct
42 Correct 13 ms 55252 KB Output is correct
43 Correct 11 ms 47452 KB Output is correct
44 Correct 115 ms 70516 KB Output is correct
45 Correct 14 ms 55248 KB Output is correct
46 Correct 14 ms 55504 KB Output is correct
47 Correct 16 ms 55508 KB Output is correct
48 Correct 18 ms 56100 KB Output is correct
49 Correct 23 ms 57044 KB Output is correct
50 Correct 25 ms 57808 KB Output is correct
51 Correct 70 ms 63972 KB Output is correct
52 Runtime error 59 ms 111820 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -