結果

問題 No.2124 Guess the Permutation
ユーザー 👑 CleyL
提出日時 2022-12-21 01:35:58
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 72,008 KB
最終ジャッジ日時 2025-02-09 17:48:21
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

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