Submission #538102

# Submission time Handle Problem Language Result Execution time Memory
538102 2022-03-16T05:26:38 Z huangqr Library (JOI18_library) C++14
0 / 100
42 ms 308 KB
#include <cstdio>
#include <vector>
#include "library.h"

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

void Solve(int N)
{
	vector<int>M(N,1);
	vector<int>ans;
	vector<int>unknown;
	for(int i=1;i<=N;i++)unknown.push_back(i);
	for(int i=0;i<N;i++){//Locating an edge, letting it be L
		M[i]=0;
		if(Query(M)==1){
			ans.push_back(i+1);
			unknown.erase(remove(unknown.begin(),unknown.end(),i+1),unknown.end());
			break;
		}
		M[i]=1;
	}
	while((int)ans.size()<N){
		vector<int>space=unknown,a,b;
		while(space.size()>1){
			int halfsize=space.size()/2;
			for(int i=0;i<halfsize;i++){
				a.push_back(space[i]);
			}
			for(int i=halfsize;i<(int)space.size();i++){
				b.push_back(space[i]);
			}
			fill(M.begin(),M.end(),0);
			for(auto x:a)M[x-1]=1;
			int pre = Query(M);
			M[ans.back()-1]=1;
			int aft = Query(M);
			if(pre==aft)space=a;
			else space=b;
			a.clear();
			b.clear();
		}
		ans.push_back(*(space.begin()));
		unknown.erase(remove(unknown.begin(),unknown.end(),*(space.begin())),unknown.end());
	}
	Answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 30 ms 208 KB # of queries: 2375
2 Correct 35 ms 308 KB # of queries: 2409
3 Correct 36 ms 308 KB # of queries: 2648
4 Correct 37 ms 300 KB # of queries: 2595
5 Correct 34 ms 208 KB # of queries: 2508
6 Correct 34 ms 304 KB # of queries: 2551
7 Correct 37 ms 304 KB # of queries: 2544
8 Correct 33 ms 208 KB # of queries: 2420
9 Correct 42 ms 300 KB # of queries: 2546
10 Correct 20 ms 304 KB # of queries: 1474
11 Runtime error 0 ms 208 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 208 KB # of queries: 2375
2 Correct 35 ms 308 KB # of queries: 2409
3 Correct 36 ms 308 KB # of queries: 2648
4 Correct 37 ms 300 KB # of queries: 2595
5 Correct 34 ms 208 KB # of queries: 2508
6 Correct 34 ms 304 KB # of queries: 2551
7 Correct 37 ms 304 KB # of queries: 2544
8 Correct 33 ms 208 KB # of queries: 2420
9 Correct 42 ms 300 KB # of queries: 2546
10 Correct 20 ms 304 KB # of queries: 1474
11 Runtime error 0 ms 208 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -