結果
| 問題 |
No.2577 Simple Permutation Guess
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-12-08 20:54:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
QLE
|
| 実行時間 | - |
| コード長 | 1,023 bytes |
| コンパイル時間 | 1,887 ms |
| コンパイル使用メモリ | 170,896 KB |
| 実行使用メモリ | 25,476 KB |
| 平均クエリ数 | 251.96 |
| 最終ジャッジ日時 | 2024-09-27 03:06:44 |
| 合計ジャッジ時間 | 15,304 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 110 QLE * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
/*
* 方針
* 先頭から二分探索で確定させていく。
* 投げる順列Qは、
* 確定部分P+(残りの要素の中、先頭がqである順列の最も「小さい」順列)、すなわち
* P,q,1,2,...,q-1,q+1,...,n
*/
vector<int> P; //確定
vector<int> Q(n); //暫定
iota(Q.begin(),Q.end(),1);
while(Q.size()){
int left=0;
int right=Q.size();
while(right-left>1){
int mid=(left+right)/2;
cout << '?';
for(int p:P){
cout << ' ' << p;
}
cout << ' ' << Q[mid];
for(int q=0;q<Q.size();q++){
if(q!=mid){
cout << ' ' << Q[q];
}
}
cout << endl << flush;
int ret;
cin >> ret;
if(ret==1){//答えはQ以上
left=mid;
}else if(ret==0){//答えは小さい
right=mid;
}else{
abort();
}
}
P.push_back(Q[left]);
Q.erase(Q.begin()+left);
}
cout << '!';
for(int p:P){
cout << ' ' << p;
}
cout << endl << flush;
return 0;
}