結果
問題 |
No.3237 Find the Treasure!
|
ユーザー |
![]() |
提出日時 | 2025-08-15 22:57:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,943 bytes |
コンパイル時間 | 1,949 ms |
コンパイル使用メモリ | 207,400 KB |
実行使用メモリ | 26,356 KB |
平均クエリ数 | 16.00 |
最終ジャッジ日時 | 2025-08-15 22:57:36 |
合計ジャッジ時間 | 10,039 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;} template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int N; vector<int> E[101010]; int U[101010],V[101010]; int D[101010]; void dfs(int cur,int pre,int d) { D[cur]=d; FORR(e,E[cur]) if(e!=pre) dfs(e,cur,d^1); } void solve() { int i,j,k,l,r,x,y; string s; cin>>N; FOR(i,N-1) { cin>>U[i]>>V[i]; E[U[i]].push_back(V[i]); E[V[i]].push_back(U[i]); } dfs(1,1,0); cout<<"?"; FOR(i,N-1) { if(D[U[i]]) cout<<" "<<V[i]; else cout<<" "<<U[i]; } cout<<endl; cin>>s; vector<int> cand; if(s=="Yes") { FOR(i,N-1) { if(D[U[i]]==0) cand.push_back(U[i]); else cand.push_back(V[i]); } } else { FOR(i,N-1) { if(D[V[i]]==0) cand.push_back(U[i]); else cand.push_back(V[i]); } } FOR(i,14) { set<int> X[2]; FOR(j,cand.size()) X[j%2].insert(cand[j]); cout<<"?"; FOR(j,N-1) { if(X[0].count(U[i])) { cout<<" "<<U[i]; } else if(X[0].count(V[i])) { cout<<" "<<V[i]; } else if(X[1].count(U[i])) { cout<<" "<<V[i]; } else if(X[1].count(V[i])) { cout<<" "<<U[i]; } else { cout<<" "<<U[i]; } } cout<<endl; cin>>s; cand.clear(); FORR(x,X[s=="No"]) cand.push_back(x); } cout<<"! "<<cand[0]<<endl; } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }