結果
| 問題 | 
                            No.2848 Birthday Hit and Blow
                             | 
                    
| コンテスト | |
| ユーザー | 
                             FplusFplusF
                         | 
                    
| 提出日時 | 2024-08-23 22:37:15 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,873 bytes | 
| コンパイル時間 | 3,462 ms | 
| コンパイル使用メモリ | 270,176 KB | 
| 実行使用メモリ | 220,964 KB | 
| 平均クエリ数 | 6.00 | 
| 最終ジャッジ日時 | 2024-08-23 22:37:21 | 
| 合計ジャッジ時間 | 5,363 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | RE * 1 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++)
#define all(v) v.begin(),v.end()
#define len(v) ((ll)v.size())
template<class T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
vector<string> day,q_day;
vector<ll> day_ll,q_day_ll;
pll mp[10000][1300];
void solve(){
    vector<ll> ans=day_ll,new_ans;
    while(1<len(ans)){
        ll query_ll=-1;
        ll mn=INF;
        for(auto i:q_day_ll){
            vector<vector<ll>> cnt(5,vector<ll>(5,0));
            for(auto j:ans){
                auto [p,q]=mp[i][j];
                cnt[p][q]++;
            }
            ll mx=-INF;
            rep(a,5){
                rep(b,5){
                    chmax(mx,cnt[a][b]);
                }
            }
            if(chmin(mn,mx)) query_ll=i;
        }
        string query=to_string(query_ll);
        if(len(query)<4) query="0"+query;
        cout << "? " << query << '\n';
        cout.flush();
        ll h,b;
        cin >> h >> b;
        assert(h!=-1&&b!=-1);
        for(auto j:ans){
            auto [p,q]=mp[query_ll][j];
            if(h==p&&b==q) new_ans.push_back(j);
        }
        swap(ans,new_ans);
        new_ans.clear();
    }
    assert(!ans.empty());
    string ans_str=to_string(*ans.begin());
    if(len(ans_str)<4) ans_str="0"+ans_str;
    cout << "! " << ans_str << '\n';
    cout.flush();
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<ll> d={31,29,31,30,31,30,31,31,30,31,30,31};
    replr(i,1,13){
        replr(j,1,d[i-1]+1){
            string x=to_string(i),y=to_string(j);
            if(len(x)<=1) x="0"+x;
            if(len(y)<=1) y="0"+y;
            day.push_back(x+y);
            day_ll.push_back(stoll(x+y));
        }
    }
    rep(i,100){
        rep(j,100){
            string x=to_string(i),y=to_string(j);
            if(len(x)<=1) x="0"+x;
            if(len(y)<=1) y="0"+y;
            set<char> st={x[0],x[1],y[0],y[1]};
            if(len(st)==4){
                q_day.push_back(x+y);
                q_day_ll.push_back(stoll(x+y));
            }
        }
    }
    for(auto s:q_day){
        for(auto t:day){
            ll p=0,q=0;
            rep(i,4){
                rep(j,4){
                    if(s[i]==t[j]){
                        if(i==j) p++;
                        else q++;
                    }
                }
            }
            mp[stoll(s)][stoll(t)]={p,q};
        }
    }
    ll t;
    cin >> t;
    while(t--){
        solve();
    }
}
            
            
            
        
            
FplusFplusF