답안 #919328

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919328 2024-01-31T15:14:13 Z ttamx 도서관 (JOI18_library) C++14
0 / 100
28 ms 440 KB
#include <bits/stdc++.h>
#include "library.h"

using namespace std;

void Solve(int n){
	vector<int> a(n);
	iota(a.begin(),a.end(),0);
	auto del=[&](int x){
		assert(x<a.size());
		a.erase(a.begin()+x);
	};
	vector<int> qr(n,1);
	int st=-1;
	for(int i=0;i<n;i++){
		qr[i]=0;
		if(Query(qr)==1){
			st=i;
			break;
		}
		qr[i]=1;
	}
	assert(st!=-1);
	del(st);
	vector<int> ans{st};
	for(int t=1;t<n;t++){
		int l=1,r=n-t;
		while(l<r){
			int m=(l+r)/2;
			qr.assign(n,0);
			for(int i=0;i<m;i++)qr[a[i]]=1;
			int res=Query(qr);
			qr[ans.back()]=1;
			if(Query(qr)==res)r=m;
			else l=m+1;
		}
		ans.emplace_back(a[l-1]);
		del(l-1);
	}
	for(auto &x:ans)x++;
	Answer(ans);
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from library.cpp:1:
library.cpp: In lambda function:
library.cpp:10:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   assert(x<a.size());
      |          ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 436 KB # of queries: 2387
2 Correct 22 ms 436 KB # of queries: 2433
3 Correct 27 ms 440 KB # of queries: 2638
4 Correct 22 ms 436 KB # of queries: 2593
5 Correct 23 ms 440 KB # of queries: 2504
6 Correct 21 ms 436 KB # of queries: 2553
7 Correct 24 ms 436 KB # of queries: 2568
8 Correct 28 ms 436 KB # of queries: 2402
9 Correct 21 ms 432 KB # of queries: 2512
10 Correct 15 ms 432 KB # of queries: 1478
11 Runtime error 1 ms 440 KB Execution killed with signal 6
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 436 KB # of queries: 2387
2 Correct 22 ms 436 KB # of queries: 2433
3 Correct 27 ms 440 KB # of queries: 2638
4 Correct 22 ms 436 KB # of queries: 2593
5 Correct 23 ms 440 KB # of queries: 2504
6 Correct 21 ms 436 KB # of queries: 2553
7 Correct 24 ms 436 KB # of queries: 2568
8 Correct 28 ms 436 KB # of queries: 2402
9 Correct 21 ms 432 KB # of queries: 2512
10 Correct 15 ms 432 KB # of queries: 1478
11 Runtime error 1 ms 440 KB Execution killed with signal 6
12 Halted 0 ms 0 KB -