結果

問題 No.3237 Find the Treasure!
ユーザー tails
提出日時 2025-08-15 23:02:29
言語 cLay
(20241019-1)
結果
AC  
実行時間 479 ms / 3,000 ms
コード長 632 bytes
コンパイル時間 3,336 ms
コンパイル使用メモリ 196,812 KB
実行使用メモリ 26,228 KB
平均クエリ数 14.00
最終ジャッジ日時 2025-08-15 23:03:00
合計ジャッジ時間 14,715 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

//interactive
int@n;
if(n==1){
	wt("! 1");
	exit(0);
}
int@(u,v)[n-1];
graph g;
g.setEdge(n+1,n-1,u,v);
int d[n+1];
g.getDist(1,d);
unordered_set<int>s,s0,s1;
rep(i,1,n+1){
	(d[i]&1?s1:s0).insert(i);
}
wtN('?');
rep(j,n-1){
	wtN(' ');
	wtN(s1.count(u[j])?u[j]:v[j]);
}
wt("");
string@r;
int b=r[0]=='Y';
s=b?s1:s0;
s0.clear();
s1.clear();
while(s.size()>1){
	int p=0;
	for(auto t:s){
		(p?s1:s0).insert(t);
		p^=1;
	}
	wtN('?');
	rep(j,n-1){
		wtN(' ');
dprintf(2,"hoge\n");
		wtN(s1.count(u[j])||!s1.count(v[j])&&(d[u[j]]&1)!=b?u[j]:v[j]);
	}
	wt("");
	string@r;
	s=r[0]=='Y'?s1:s0;
	s0.clear();
	s1.clear();
}
wt("!",*s.begin());
0