結果
| 問題 |
No.2848 Birthday Hit and Blow
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2024-08-23 22:23:22 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,558 bytes |
| コンパイル時間 | 4,475 ms |
| コンパイル使用メモリ | 285,500 KB |
| 実行使用メモリ | 250,824 KB |
| 最終ジャッジ日時 | 2024-08-23 22:23:36 |
| 合計ジャッジ時間 | 13,368 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 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;
map<pair<string,string>,pll> mp;
void solve(){
unordered_set<string> ans(all(day)),new_ans;
while(1<len(ans)){
string query;
ll mn=INF;
for(auto i:q_day){
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=i;
}
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,j}];
if(h==p&&b==q) new_ans.insert(j);
}
swap(ans,new_ans);
new_ans.clear();
}
assert(!ans.empty());
cout << "! " << *ans.begin() << '\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);
}
}
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);
}
}
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[{s,t}]={p,q};
}
}
ll t;
cin >> t;
while(t--){
solve();
}
}
FplusFplusF