답안 #469310

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
469310 2021-08-31T12:02:30 Z keta_tsimakuridze 도서관 (JOI18_library) C++14
0 / 100
56 ms 200 KB
#include<bits/stdc++.h>
#include "library.h"
#define f first
#define s second
#define pii pair<int,int>
using namespace std;
const int N = 1e3 + 5, mod = 1e9 + 7; // !
int t, used[N],n;
/*
int Query(vector<int> v){
	for(int j = 0; j < n; j++) {
		cout << v[j] <<" ";
	}
	cout << endl;
	int x;
	cin >> x;
	return x;
}
void Answer(vector<int> ans){
	for(int i = 0; i < n; i++) {
		cout << ans[i];
	}	
}
*/
int ask(vector<int> v) {
return Query(v);}

void Solve(int n) {
	vector<int> v(n),ans(n);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++){
			if(i == j) v[i] = 0;
			else v[j] = 1;
		}
		if(ask(v) == 1) {
			ans[0] = i;
			used[ans[0]] = 1;
			for(int j = 0; j < n; j ++) v[j] = 0;
			break;
		}
	}
	for(int i = 1; i < n; i++){
		#define left Left
		vector<int> left;
		for(int j = 0; j < n; j++){
			if(!used[j]) left.push_back(j);
		}
		int l = 0, r = left.size(); r--;
		while(l <= r){
			int mid = (l + r) / 2;
			for(int j = 0; j < left.size(); j++){
				if(j <= mid) v[left[j]] = 1;
				else v[left[j]] = 0;
			}
			v[ans[i - 1]] = 1;
			int c1 = ask(v);
			v[ans[i - 1]] = 0;
			int c2 = ask(v);
			if(c1 == c2) ans[i] = left[mid], r = mid - 1;
			else l = mid + 1;
		}
		used[ans[i]] = 1;
	}
	for(int i = 0; i < n; i++) ++ans[i];	
	Answer(ans);
}
/*
main(){
	cin >> n;
	solve(n);
 }
*/

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:51:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |    for(int j = 0; j < left.size(); j++){
      |                   ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 200 KB # of queries: 2401
2 Correct 50 ms 200 KB # of queries: 2437
3 Correct 39 ms 200 KB # of queries: 2658
4 Correct 56 ms 200 KB # of queries: 2597
5 Correct 53 ms 200 KB # of queries: 2526
6 Correct 43 ms 200 KB # of queries: 2565
7 Correct 47 ms 200 KB # of queries: 2556
8 Correct 41 ms 200 KB # of queries: 2424
9 Correct 49 ms 200 KB # of queries: 2550
10 Correct 25 ms 200 KB # of queries: 1488
11 Runtime error 1 ms 200 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 200 KB # of queries: 2401
2 Correct 50 ms 200 KB # of queries: 2437
3 Correct 39 ms 200 KB # of queries: 2658
4 Correct 56 ms 200 KB # of queries: 2597
5 Correct 53 ms 200 KB # of queries: 2526
6 Correct 43 ms 200 KB # of queries: 2565
7 Correct 47 ms 200 KB # of queries: 2556
8 Correct 41 ms 200 KB # of queries: 2424
9 Correct 49 ms 200 KB # of queries: 2550
10 Correct 25 ms 200 KB # of queries: 1488
11 Runtime error 1 ms 200 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -