結果

問題 No.2124 Guess the Permutation
ユーザー CleyLCleyL
提出日時 2022-12-21 01:35:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 73,728 KB
実行使用メモリ 25,220 KB
平均クエリ数 374.60
最終ジャッジ日時 2024-04-29 03:07:48
合計ジャッジ時間 1,671 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
24,556 KB
testcase_01 AC 17 ms
24,580 KB
testcase_02 AC 18 ms
24,836 KB
testcase_03 AC 24 ms
24,836 KB
testcase_04 AC 21 ms
24,580 KB
testcase_05 AC 22 ms
25,220 KB
testcase_06 AC 36 ms
24,836 KB
testcase_07 AC 51 ms
24,836 KB
testcase_08 AC 45 ms
25,076 KB
testcase_09 AC 46 ms
24,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> A(n);
  int sm = n*(n+1)/2;
  for(int i = 0; n-2 > i; i++){
    cout << "? " << 1 << " " << n-i-1 << endl;
    int x;cin>>x;
    A[n-i-1] = sm-x;
    sm = x;
  }
  cout << "? 2 3" << endl;
  int x;cin>>x;
  A[1] = x-A[2];
  A[0] = sm-A[1];
  cout << "! ";
  for(int i = 0; n > i; i++){
    cout << A[i] << " ";
  }
  cout << endl;
}
0