結果
| 問題 |
No.2124 Guess the Permutation
|
| コンテスト | |
| ユーザー |
forest3
|
| 提出日時 | 2022-12-12 23:30:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 2,000 ms |
| コード長 | 631 bytes |
| コンパイル時間 | 1,721 ms |
| コンパイル使用メモリ | 169,156 KB |
| 実行使用メモリ | 25,348 KB |
| 平均クエリ数 | 374.60 |
| 最終ジャッジ日時 | 2024-11-06 21:04:48 |
| 合計ジャッジ時間 | 3,225 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#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;
}
forest3