結果

問題 No.2124 Guess the Permutation
ユーザー kotatsugamekotatsugame
提出日時 2022-11-18 21:25:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 64,860 KB
実行使用メモリ 24,612 KB
平均クエリ数 374.60
最終ジャッジ日時 2023-10-20 06:12:18
合計ジャッジ時間 1,774 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
24,612 KB
testcase_01 AC 23 ms
24,612 KB
testcase_02 AC 24 ms
24,612 KB
testcase_03 AC 23 ms
24,612 KB
testcase_04 AC 24 ms
24,612 KB
testcase_05 AC 26 ms
24,612 KB
testcase_06 AC 41 ms
24,612 KB
testcase_07 AC 56 ms
24,612 KB
testcase_08 AC 55 ms
24,612 KB
testcase_09 AC 55 ms
24,612 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
int P[1001];
main()
{
	cin>>N;
	int prv=N*(N+1)/2;
	for(int i=2;i<N;i++)
	{
		cout<<"? "<<i<<" "<<N<<endl;
		int t;cin>>t;
		P[i-1]=prv-t;
		prv=t;
	}
	cout<<"? "<<N-2<<" "<<N-1<<endl;
	int t;cin>>t;
	P[N-1]=t-P[N-2];
	t=N*(N+1)/2;
	for(int i=1;i<N;i++)t-=P[i];
	P[N]=t;
	cout<<"!";
	for(int i=1;i<=N;i++)cout<<" "<<P[i];
	cout<<endl;
}
0