Submission #62597

# Submission time Handle Problem Language Result Execution time Memory
62597 2018-07-29T09:26:19 Z gusfring Library (JOI18_library) C++14
100 / 100
696 ms 596 KB
#include <bits/stdc++.h>
#include "library.h"

using namespace std;
 
int n;
 
int ask(vector<int> &V){
	return Query(V);
}
 
int find1(int n){
	if(n==1) return 0;
	vector<int> M(n);
	for(int i=0; i<n; ++i) M[i]=1;
	for(int i=0; i<n; ++i){
		M[i] = 0;
		if(ask(M) == 1) return i;
		M[i] = 1;
	}
	return 0;
}
 
vector<int> X, Y;
vector<bool> done;
 
int findnext(int s, int e, vector<int> &V){
	if(s==e) return V[s];
	if(s>e) return 0;
	int m = (s + e) / 2;
	for(int i=s; i<=m; ++i) X[V[i]] = Y[V[i]] = 1;
	int a=ask(X), b=ask(Y);
	for(int i=s; i<=m; ++i) X[V[i]] = Y[V[i]] = 0;
	if(a == b) return findnext(s, m, V);
	else return findnext(m+1, e, V);
}
 
void Solve(int N){
	n = N;
	X.resize(n, 0);
	Y.resize(n, 0);
	done.resize(n, false);
	vector<int> ans(n);
	int p = find1(n);
	X[p] = 1;
	ans[0] = p + 1;
	done[p] = true;
	for(int i=1; i<n; ++i){
		vector<int> V;
		for(int i=0; i<n; ++i) if(!done[i]) V.push_back(i);
		int nxt = findnext(0, V.size()-1, V);
		ans[i] = nxt + 1;
		done[nxt] = true;
		X[nxt] = 1;
	}
	Answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 52 ms 248 KB Output is correct
2 Correct 45 ms 308 KB Output is correct
3 Correct 57 ms 344 KB Output is correct
4 Correct 60 ms 392 KB Output is correct
5 Correct 47 ms 596 KB Output is correct
6 Correct 49 ms 596 KB Output is correct
7 Correct 62 ms 596 KB Output is correct
8 Correct 61 ms 596 KB Output is correct
9 Correct 44 ms 596 KB Output is correct
10 Correct 28 ms 596 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 3 ms 596 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 4 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 248 KB Output is correct
2 Correct 45 ms 308 KB Output is correct
3 Correct 57 ms 344 KB Output is correct
4 Correct 60 ms 392 KB Output is correct
5 Correct 47 ms 596 KB Output is correct
6 Correct 49 ms 596 KB Output is correct
7 Correct 62 ms 596 KB Output is correct
8 Correct 61 ms 596 KB Output is correct
9 Correct 44 ms 596 KB Output is correct
10 Correct 28 ms 596 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 3 ms 596 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 4 ms 596 KB Output is correct
17 Correct 682 ms 596 KB Output is correct
18 Correct 525 ms 596 KB Output is correct
19 Correct 624 ms 596 KB Output is correct
20 Correct 573 ms 596 KB Output is correct
21 Correct 501 ms 596 KB Output is correct
22 Correct 558 ms 596 KB Output is correct
23 Correct 531 ms 596 KB Output is correct
24 Correct 190 ms 596 KB Output is correct
25 Correct 667 ms 596 KB Output is correct
26 Correct 583 ms 596 KB Output is correct
27 Correct 216 ms 596 KB Output is correct
28 Correct 676 ms 596 KB Output is correct
29 Correct 696 ms 596 KB Output is correct
30 Correct 647 ms 596 KB Output is correct