結果

問題 No.2124 Guess the Permutation
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-04-22 21:08:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 713 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 64,608 KB
実行使用メモリ 25,580 KB
平均クエリ数 374.60
最終ジャッジ日時 2024-04-24 23:28:11
合計ジャッジ時間 2,239 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
25,580 KB
testcase_01 AC 23 ms
24,964 KB
testcase_02 AC 24 ms
24,836 KB
testcase_03 AC 24 ms
24,836 KB
testcase_04 AC 26 ms
24,836 KB
testcase_05 AC 27 ms
24,836 KB
testcase_06 AC 44 ms
24,836 KB
testcase_07 AC 59 ms
24,836 KB
testcase_08 AC 58 ms
24,836 KB
testcase_09 AC 58 ms
24,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>
#include <string.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	long long int all=0;
	set<long long int> ss;
	
	cin>>n;
	for(int i=1;i<=n;i++){
		all+=i;
		ss.insert(i);
	}
	long long int ans[1003],ds[1003];
	memset(ans,0,sizeof(ans));
	memset(ds,0,sizeof(ds));
	long long int t;
	for(int i=2;i<n;i++){
		cout<<"? "<<i<<" "<<n<<endl;
		cout<<flush;
		cin>>t;
		ds[i]=t;
		ans[i-1]=all-t;
		all-=ans[i-1];
		ss.erase(ans[i-1]);
	}
	cout<<"? "<<n-2<<" "<<n-1<<endl;
	cout<<flush;
	cin>>t;
	ans[n-1]=t-ans[n-2];
	ss.erase(ans[n-1]);
	ans[n]=(*(ss.begin()));
	cout<<"!";
	for(int i=1;i<=n;i++){
		cout<<" "<<ans[i];
	}
	cout<<endl;
	cout<<flush;
	return 0;
}
0