Submission #101111

# Submission time Handle Problem Language Result Execution time Memory
101111 2019-03-16T17:00:50 Z gs14004 Library (JOI18_library) C++17
0 / 100
559 ms 4328 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;
const int MAXN = 1005;

int n;
int dp[MAXN][MAXN];

int query(int s, int e){
	if(s > e) return 0;
	if(dp[s][e]) return dp[s][e];
	vector<int> v(n);
	fill(v.begin() + s, v.begin() + e + 1, 1);
	return dp[s][e] = Query(v);
}

vector<int> gph[MAXN];
vector<int> dfn;

void dfs(int x, int p){
	dfn.push_back(x + 1);
	for(auto &i : gph[x]){
		if(i != p){
			dfs(i, x);
		}
	}
}

void Solve(int N){
	n = N;
	for(int i=1; i<N; i++){
		int interesting = query(0, i - 1) + 1 - query(0, i);
		for(int j=0; j<interesting; j++){
			int s = 1, e = i;
			while(s != e){
				int m = (s + e) / 2;
				if(query(m, i) >= query(m, i - 1) + 1 - j){
					e = m;
				}
				else s = m + 1;
			}
			gph[i].push_back(s - 1);
			gph[s - 1].push_back(i);
		//	printf("has edge %d %d\n", s - 1, i);
		}
	}
	for(int i=0; i<N; i++){
		if(gph[i].size() == 1){
			dfs(i, -1);
			break;
		}
	}
	Answer(dfn);
}
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1016 KB # of queries: 2388
2 Correct 25 ms 980 KB # of queries: 2435
3 Correct 60 ms 1064 KB # of queries: 2483
4 Correct 37 ms 1016 KB # of queries: 2544
5 Correct 32 ms 984 KB # of queries: 2512
6 Correct 46 ms 1080 KB # of queries: 2484
7 Correct 48 ms 952 KB # of queries: 2577
8 Correct 47 ms 952 KB # of queries: 2433
9 Correct 51 ms 1080 KB # of queries: 2529
10 Correct 26 ms 860 KB # of queries: 1461
11 Incorrect 2 ms 384 KB Wrong Answer [4]
12 Correct 2 ms 256 KB # of queries: 2
13 Correct 2 ms 384 KB # of queries: 5
14 Correct 2 ms 440 KB # of queries: 9
15 Correct 3 ms 432 KB # of queries: 74
16 Correct 6 ms 384 KB # of queries: 174
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1016 KB # of queries: 2388
2 Correct 25 ms 980 KB # of queries: 2435
3 Correct 60 ms 1064 KB # of queries: 2483
4 Correct 37 ms 1016 KB # of queries: 2544
5 Correct 32 ms 984 KB # of queries: 2512
6 Correct 46 ms 1080 KB # of queries: 2484
7 Correct 48 ms 952 KB # of queries: 2577
8 Correct 47 ms 952 KB # of queries: 2433
9 Correct 51 ms 1080 KB # of queries: 2529
10 Correct 26 ms 860 KB # of queries: 1461
11 Incorrect 2 ms 384 KB Wrong Answer [4]
12 Correct 2 ms 256 KB # of queries: 2
13 Correct 2 ms 384 KB # of queries: 5
14 Correct 2 ms 440 KB # of queries: 9
15 Correct 3 ms 432 KB # of queries: 74
16 Correct 6 ms 384 KB # of queries: 174
17 Correct 559 ms 4160 KB # of queries: 17517
18 Correct 522 ms 4144 KB # of queries: 17184
19 Correct 454 ms 4148 KB # of queries: 17448
20 Correct 404 ms 3804 KB # of queries: 16160
21 Correct 361 ms 3684 KB # of queries: 15233
22 Correct 480 ms 4216 KB # of queries: 17402
23 Correct 499 ms 4244 KB # of queries: 17463
24 Correct 155 ms 2296 KB # of queries: 7880
25 Correct 437 ms 3972 KB # of queries: 17069
26 Correct 427 ms 3760 KB # of queries: 15873
27 Correct 124 ms 2252 KB # of queries: 7892
28 Correct 446 ms 4328 KB # of queries: 15472
29 Correct 340 ms 4316 KB # of queries: 15453
30 Correct 358 ms 4264 KB # of queries: 15472