結果
| 問題 |
No.2577 Simple Permutation Guess
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-12-13 23:04:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
QLE
|
| 実行時間 | - |
| コード長 | 1,769 bytes |
| コンパイル時間 | 2,042 ms |
| コンパイル使用メモリ | 184,088 KB |
| 実行使用メモリ | 274,964 KB |
| 平均クエリ数 | 252.57 |
| 最終ジャッジ日時 | 2024-09-27 05:32:18 |
| 合計ジャッジ時間 | 15,594 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 61 QLE * 50 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define debug 0
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
using ll = long long;
using ld = long double;
const int mod = 998244353;
const int MOD = 1000000007;
const double pi = atan2(0, -1);
#include <time.h>
#include <chrono>
int main() {
int n;
cin >> n;
vector<int> list(n + 1);
rep(i, n + 1) {
list[i] = i + 1;
}
vector<int> ans;
set<int> res;
rep(i, n) {
res.insert(i + 1);
}
if (n <= 10) {
vector<vector<int>> all;
vector<int> v(n);
rep(i, n) {
v[i] = i + 1;
}
do {
all.push_back(v);
} while (next_permutation(v.begin(), v.end()));
int l = 0, r = all.size();
while (r > l + 1) {
int mid = (l + r) / 2;
cout << "? ";
for (int x : all[mid]) {
cout << x << " ";
}
cout << endl;
int ret;
cin >> ret;
if (ret == 0) {
r = mid;
}
else {
l = mid;
}
}
cout << "! ";
for (int x : all[l]) {
cout << x << " ";
}
cout << endl;
return 0;
}
int cnt = 0;
rep(i, n) {
int l = i, r = n;
while (r > l + 1) {
//Query
int mid = (l + r) / 2;
cout << "? ";
for (int x : ans) {
cout << x << " ";
}
cout << list[mid] << " ";
for (int x : res) {
if (x != list[mid]) {
cout << x << " ";
}
}
cout << endl;
cnt++;
int ret;
cin >> ret;
if (ret == 0) {
r = mid;
}
if (ret == 1) {
l = mid;
}
}
ans.push_back(list[l]);
res.erase(list[l]);
list[l] = -1;
sort(list.begin(), list.end());
}
cout << "! ";
for (int x : ans) {
cout << x << " ";
}
cout << endl;
cout << "Query=" << cnt << endl;
cout << "Limit=" << floor(floor((n - 1) * log2(n)) - (double)(n - 1) / 2 + 1) << endl;
}