結果

問題 No.3347 Guess The Array
コンテスト
ユーザー kotatsugame
提出日時 2025-11-13 23:42:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 789 bytes
コンパイル時間 889 ms
コンパイル使用メモリ 73,564 KB
実行使用メモリ 26,576 KB
平均クエリ数 4953.07
最終ジャッジ日時 2025-11-13 23:43:15
合計ジャッジ時間 17,226 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 WA * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
int N;
bool ask(vector<int>B)
{
	if(N<B.size())return false;
	cout<<"? "<<B.size();
	for(int b:B)cout<<" "<<b;
	cout<<endl;
	string s;
	cin>>s;
	return s=="Yes";
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N;
	vector<int>B;
	for(int a=1;a<=N;a++)
	{
		for(int cnt=0;;cnt++)
		{
			int f=0;
			if(cnt>0)
			{
				while(B[f++]!=a);
			}
			{
				vector<int>C(B.begin(),B.begin()+f);
				C.push_back(a);
				if(!ask(C))break;
			}
			int L=f,R=B.size()+1;
			while(R-L>1)
			{
				int mid=(L+R)/2;
				vector<int>C(B.begin(),B.begin()+mid);
				C.push_back(a);
				if(ask(C))L=mid;
				else R=mid;
			}
			B.insert(B.begin()+L,a);
		}
	}
	cout<<"!";
	for(int a:B)cout<<" "<<a;
	cout<<endl;
}
0