結果
| 問題 |
No.2848 Birthday Hit and Blow
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2024-08-23 22:56:39 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 74 ms / 2,000 ms |
| コード長 | 2,906 bytes |
| コンパイル時間 | 3,566 ms |
| コンパイル使用メモリ | 265,232 KB |
| 実行使用メモリ | 50,760 KB |
| 平均クエリ数 | 459.50 |
| 最終ジャッジ日時 | 2024-08-23 22:56:44 |
| 合計ジャッジ時間 | 4,589 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 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);
while(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());
while(len(ans_str)<4) ans_str="0"+ans_str;
cout << "! " << ans_str << '\n';
cout.flush();
ll a;
cin >> a;
assert(a==0);
}
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);
while(len(x)<=1) x="0"+x;
while(len(y)<=1) y="0"+y;
day.push_back(x+y);
day_ll.push_back(stoll(x+y));
}
}
q_day_ll={123,124,126,127,128,132,134,136,142,148,158,167,178,184,236,243,245,267,275,312,316,318,327,361,365,367,415,478,536,637,657,674,718,1053,1267,1306,1307,1608,3147,4521,6172,6780};
for(auto i:q_day_ll){
string now=to_string(i);
while(len(now)<4) now="0"+now;
q_day.push_back(now);
}
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