結果
| 問題 |
No.3347 Guess The Array
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-14 10:34:40 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 449 ms / 2,000 ms |
| コード長 | 1,900 bytes |
| コンパイル時間 | 2,764 ms |
| コンパイル使用メモリ | 285,216 KB |
| 実行使用メモリ | 26,096 KB |
| 平均クエリ数 | 3886.20 |
| 最終ジャッジ日時 | 2025-11-14 10:35:02 |
| 合計ジャッジ時間 | 19,915 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 46 |
ソースコード
// つら
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define fast cin.tie(nullptr); ios_base::sync_with_stdio(false)
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll mod = 998244353;
bool query(vector<int> &b){
int s = b.size();
cout << "? " << s << " ";
for(int i=0;i<s;i++) cout << b[i] << (i==s-1 ? "\n" : " ");
cout.flush();
string res;
cin >> res;
return res == "Yes";
}
int n;
int main(){
fast;
cin >> n;
vector<int> cnt(n + 1);
int rem = n;
for(int i = 1; i <= n; i++){
if(rem == 0) break;
vector<int> tmp;
int c = 0;
for(int j = 1; j <= rem; j++){
tmp.eb(i);
if(!query(tmp)){
c = j - 1;
break;
}
c = j;
}
cnt[i] = c;
rem -= cnt[i];
}
vector<int> ans = vector<int>(cnt[1],1);
for(int i = 2; i <= n; i++){
if(cnt[i] == 0) continue;
vector<int> base = ans;
int s = (int)base.size();
vector<int> add(s + 1, 0);
for(int k = 1; k <= cnt[i]; k++){
int l = 0, r = s + 1;
while(r - l > 1){
int m = (l + r) / 2;
vector<int> tmp;
tmp.reserve(m + k);
for(int j = 0; j < m; j++) tmp.eb(base[j]);
for(int j = 0; j < k; j++) tmp.eb(i);
if(query(tmp)) l = m;
else r = m;
}
add[l]++;
}
vector<int> newans;
newans.reserve(s + cnt[i]);
for(int p = 0; p <= s; p++){
for(int t = 0; t < add[p]; t++) newans.eb(i);
if(p < s) newans.eb(base[p]);
}
ans.swap(newans);
}
cout << "! ";
for(auto &x : ans){
cout << x << " ";
}
cout << endl;
}