結果
問題 |
No.2848 Birthday Hit and Blow
|
ユーザー |
![]() |
提出日時 | 2025-08-18 01:45:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,297 bytes |
コンパイル時間 | 802 ms |
コンパイル使用メモリ | 83,672 KB |
実行使用メモリ | 25,588 KB |
平均クエリ数 | 703.50 |
最終ジャッジ日時 | 2025-08-18 01:45:37 |
合計ジャッジ時間 | 1,655 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’: main.cpp:74:47: warning: ‘c3’ may be used uninitialized [-Wmaybe-uninitialized] 74 | int c1 = h1 + b1 - 1,c2 = h2 + b2 - 1,c3 = 2 - c1 - c3; | ^~ main.cpp:74:47: note: ‘c3’ was declared here 74 | int c1 = h1 + b1 - 1,c2 = h2 + b2 - 1,c3 = 2 - c1 - c3; | ^~
ソースコード
#include <iostream> #include <string> #include <cassert> #include <vector> using namespace std; pair<int,int> query(string s){ cout << "? " << s << endl; int h,b; cin >> h >> b; return {h,b}; } void ans(string s){ cout << "! " << s << endl; int x; cin >> x; } void solve(){ int i,j; pair<int,int> p = query("0123"); if(p.first + p.second==4){ vector<string> v = {"0213","0312","0321","1023","1230"}; string st; for(auto s:v){ auto [h,_] = query(s); if(h==4) st = s; } ans(st); }else if(p.first + p.second==3){ if(p.first==3){ string s = "0x23"; string st = "0923"; for(i=4;i<9;i++){ s[1] = (char)('0' + i); auto [h,_] = query(s); if(h==4) st = s; } ans(s); }else if(p.second==3){ string s = "120x"; string st = "1209"; for(i=4;i<9;i++){ s[3] = (char)('0' + i); auto [h,_] = query(s); if(h==4) st = s; } ans(s); }else{ vector<string> s = {"0x12","0x13","0x21","0x31","10x3"}; string st; char num = '9'; for(i=4;i<9;i++){ string ss = s[i - 4]; char c = (char)('0' + i); for(j=0;j<ss.size();j++){ if(ss[j]=='x') ss[j] = c; } auto [h,b] = query(ss); if(h + b==4){ num = c; if(h==4) st = s[i - 4]; }else if(h==3){ st = s[i - 4]; } } for(i=0;i<4;i++){ if(st[i]=='x') st[i] = num; } ans(st); } }else if(p.first + p.second==2){ auto [h1,b1] = query("0435"); auto [h2,b2] = query("0637"); int c1 = h1 + b1 - 1,c2 = h2 + b2 - 1,c3 = 2 - c1 - c3; string X = "",Y = ""; if(c1==2) X = "46", Y = "57"; if(c2==2) X = "46", Y = "57"; if(c3==2) X = "48", Y = "89"; if(c1==1 && c2==1) X = "45", Y = "67"; if(c1==1 && c3==1) X = "45", Y = "89"; if(c2==1 && c3==1) X = "67", Y = "89"; string ss = "0x3y"; ss[1] = X[0]; ss[3] = Y[0]; auto [h4,b4] = query(ss); ss[1] = X[0]; ss[3] = Y[1]; auto [h5,b5] = query(ss); int c4 = h4 + b4 - 1,c5 = h5 + b5 - 1; string st = "0x1y"; if(c4==2){ if(h4==2) st[1] = X[0], st[3] = Y[0]; else st[1] = Y[0], st[3] = X[0]; }else if(c5==2){ if(h5==2) st[1] = X[0], st[3] = Y[1]; else st[1] = Y[1], st[3] = X[0]; }else{ if(c4<c5){ if(h5>=2) st[1] = X[1], st[3] = Y[1]; else st[1] = Y[1], st[3] = X[1]; }else{ if(h4>=2) st[1] = X[1], st[3] = Y[0]; else st[1] = Y[0], st[3] = X[1]; } } auto [h6,b6] = query(st); if(h6!=4) st[2] = '2'; ans(st); }else{ assert(false); } } int main(){ int i,t; cin >> t; while(t){ t--; solve(); } }