結果

問題 No.2357 Guess the Function
ユーザー kotatsugamekotatsugame
提出日時 2023-06-23 21:35:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 1,000 ms
コード長 1,100 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 73,904 KB
実行使用メモリ 24,312 KB
平均クエリ数 3.00
最終ジャッジ日時 2023-09-13 16:34:27
合計ジャッジ時間 1,783 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,616 KB
testcase_01 AC 26 ms
24,312 KB
testcase_02 AC 26 ms
23,376 KB
testcase_03 AC 26 ms
23,376 KB
testcase_04 AC 27 ms
24,024 KB
testcase_05 AC 26 ms
24,288 KB
testcase_06 AC 26 ms
23,808 KB
testcase_07 AC 27 ms
23,352 KB
testcase_08 AC 26 ms
24,024 KB
testcase_09 AC 26 ms
23,988 KB
testcase_10 AC 27 ms
24,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
				}
			}
		}
	}
}
0