Submission #96717

# Submission time Handle Problem Language Result Execution time Memory
96717 2019-02-11T12:19:45 Z Retro3014 Library (JOI18_library) C++17
19 / 100
571 ms 424 KB
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stdio.h>

#include "library.h"

using namespace std;

int q(const vector<int>& M){
	for(int i=0; i<M.size(); i++){
		if(M[i]!=0){
			return Query(M);
		}
	}return 0;
}

void Solve(int N){	
	vector<int> v(N);
	vector<int> ans(N);
	vector<bool> chk(N, 0);
	for(int i=0; i<N; i++){
		v[i] = true;
	}
	for(int i=0; i<N; i++){
		v[i] = false;
		int k = q(v);
		v[i] = true;
		if(k==1){
			ans[0] = i;
			chk[i] = true;
			break;
		}
	}
	for(int i=1; i<N; i++){
		int s = 0, e = N-1, m;
		while(s<e){
			m = (s+e)/2;
			int k1, k2;
			for(int j=0; j<N; j++){
				if(chk[j]){
					v[j] = false;
				}else if(s<=j && j<=m){
					v[j] = true;
				}else{
					v[j] = false;
				}
			}
			k1 = q(v);
			for(int j=0; j<N; j++){
				if(chk[j]){
					v[j] = true;
				}else if(s<=j && j<=m){
					v[j] = true;
				}else{
					v[j] = false;
				}
			}
			k2 = q(v);
			if(k1==k2){
				e = m;
			}else{
				s = m+1;
			}
		}
		ans[i] = s;
		chk[s] = true;
	}
	for(int i=0; i<N; i++){
		ans[i]++;
	//	cout<<ans[i]<<' '<<endl;
	}
	Answer(ans);
	return;
}

Compilation message

library.cpp: In function 'int q(const std::vector<int>&)':
library.cpp:12:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<M.size(); i++){
               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 30 ms 248 KB # of queries: 2847
2 Correct 41 ms 376 KB # of queries: 2884
3 Correct 50 ms 296 KB # of queries: 3109
4 Correct 40 ms 292 KB # of queries: 3043
5 Correct 28 ms 248 KB # of queries: 2973
6 Correct 39 ms 376 KB # of queries: 3022
7 Correct 53 ms 376 KB # of queries: 3021
8 Correct 45 ms 376 KB # of queries: 2859
9 Correct 52 ms 424 KB # of queries: 2993
10 Correct 30 ms 248 KB # of queries: 1729
11 Correct 2 ms 376 KB # of queries: 0
12 Correct 2 ms 376 KB # of queries: 2
13 Correct 2 ms 380 KB # of queries: 7
14 Correct 2 ms 248 KB # of queries: 10
15 Correct 3 ms 248 KB # of queries: 101
16 Correct 6 ms 376 KB # of queries: 245
# Verdict Execution time Memory Grader output
1 Correct 30 ms 248 KB # of queries: 2847
2 Correct 41 ms 376 KB # of queries: 2884
3 Correct 50 ms 296 KB # of queries: 3109
4 Correct 40 ms 292 KB # of queries: 3043
5 Correct 28 ms 248 KB # of queries: 2973
6 Correct 39 ms 376 KB # of queries: 3022
7 Correct 53 ms 376 KB # of queries: 3021
8 Correct 45 ms 376 KB # of queries: 2859
9 Correct 52 ms 424 KB # of queries: 2993
10 Correct 30 ms 248 KB # of queries: 1729
11 Correct 2 ms 376 KB # of queries: 0
12 Correct 2 ms 376 KB # of queries: 2
13 Correct 2 ms 380 KB # of queries: 7
14 Correct 2 ms 248 KB # of queries: 10
15 Correct 3 ms 248 KB # of queries: 101
16 Correct 6 ms 376 KB # of queries: 245
17 Incorrect 571 ms 248 KB Wrong Answer [3]
18 Correct 560 ms 376 KB # of queries: 19389
19 Correct 560 ms 420 KB # of queries: 19584
20 Correct 561 ms 376 KB # of queries: 18445
21 Correct 431 ms 248 KB # of queries: 17392
22 Correct 545 ms 252 KB # of queries: 19784
23 Correct 513 ms 248 KB # of queries: 19364
24 Correct 186 ms 248 KB # of queries: 8952
25 Correct 492 ms 248 KB # of queries: 19240
26 Correct 517 ms 248 KB # of queries: 18044
27 Correct 180 ms 248 KB # of queries: 9145
28 Correct 395 ms 248 KB # of queries: 15001
29 Correct 371 ms 248 KB # of queries: 14987
30 Correct 392 ms 376 KB # of queries: 15001