結果

問題 No.2124 Guess the Permutation
ユーザー forest3forest3
提出日時 2022-12-12 23:30:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 631 bytes
コンパイル時間 1,725 ms
コンパイル使用メモリ 164,856 KB
実行使用メモリ 25,220 KB
平均クエリ数 374.60
最終ジャッジ日時 2024-04-24 12:57:56
合計ジャッジ時間 3,084 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N, s = 0;
	cin >> N;
	vector<int> S( N - 1 ), a( N );
	cout << "? " << 1 << " " << 2 << endl;
	cin >> S[0];
	s += S[0];
	cout << "? " << 2 << " " << N << endl;
	cin >> S[1];
	s += S[1];
	for( int i = 2; i < N - 1; i++ ) {
		cout << "? " << i << " " << i + 1 << endl;
		cin >> S[i];
	}
	int all = N * (N + 1) / 2;
	a[1] = s - all;
	a[0] = S[0] - a[1];
	for( int i = 2; i < N - 1; i++ ) a[i] = S[i] - a[i - 1];
	s = 0;
	for( int i = 1; i < N - 1; i++ ) s += a[i];
	a[N - 1] = S[1] - s;
	cout << "!";
	for( int i = 0; i < N; i++ ) cout << " " << a[i];
	cout << endl;
}
0