結果
問題 | No.2357 Guess the Function |
ユーザー |
|
提出日時 | 2023-06-23 21:35:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 1,000 ms |
コード長 | 1,100 bytes |
コンパイル時間 | 752 ms |
コンパイル使用メモリ | 74,372 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 3.00 |
最終ジャッジ日時 | 2024-07-01 01:09:58 |
合計ジャッジ時間 | 1,881 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<cassert> using namespace std; vector<pair<int,int> >AB[100]; int vis[100]; int X2[100]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tm=0; for(int x1=1;x1<=100;x1++) { for(int i=0;i<100;i++)AB[i].clear(); for(int A=0;A<100;A++)for(int B=A+1;B<=100;B++) { int t=(A+x1)%B; AB[t].push_back(make_pair(A,B)); } bool out=false; for(int i=0;i<100;i++) { bool fn=false; for(int x2=1;x2<=100;x2++) { ++tm; bool same=false; for(pair<int,int>p:AB[i]) { int A=p.first,B=p.second; int t=(A+x2)%B; if(vis[t]==tm) { same=true; break; } vis[t]=tm; } if(!same) { fn=true; X2[i]=x2; break; } } if(!fn) { out=true; break; } } if(!out) { cout<<"? "<<x1<<endl; int i;cin>>i; cout<<"? "<<X2[i]<<endl; int y;cin>>y; for(pair<int,int>p:AB[i]) { int A=p.first,B=p.second; if((A+X2[i])%B==y) { cout<<"! "<<A<<" "<<B<<endl; return 0; } } } } }