結果

問題 No.2124 Guess the Permutation
ユーザー Nzt3Nzt3
提出日時 2022-11-18 21:48:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 2,222 ms
コンパイル使用メモリ 205,792 KB
実行使用メモリ 24,444 KB
平均クエリ数 374.60
最終ジャッジ日時 2023-10-20 06:36:59
合計ジャッジ時間 3,544 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,444 KB
testcase_01 AC 26 ms
24,444 KB
testcase_02 AC 26 ms
24,444 KB
testcase_03 AC 27 ms
24,444 KB
testcase_04 AC 27 ms
24,444 KB
testcase_05 AC 29 ms
24,444 KB
testcase_06 AC 44 ms
24,444 KB
testcase_07 AC 59 ms
24,444 KB
testcase_08 AC 58 ms
24,444 KB
testcase_09 AC 58 ms
24,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<bool>u(N+1);
  vector<int>ans(N);
  cout<<"? 2 "<<N<<endl;
  int S;
  cin>>S;
  ans[0]=(N+1)*(N)/2-S;
  u[ans[0]]=true;
  for(int i=1;i<N-1;i++){
    cout<<"? "<<i<<' '<<i+1<<endl;
    int s;
    cin>>s;
    ans[i]=s-ans[i-1];
    u[ans[i]]=true;
  }
  for(int i=1;i<=N;i++){
    if(!u[i])ans[N-1]=i;
  }
  cout<<'!';
  for(int i:ans)cout<<' '<<i;
  cout<<endl;
}
0