結果

問題 No.2124 Guess the Permutation
ユーザー umezoumezo
提出日時 2024-01-11 01:12:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 684 bytes
コンパイル時間 2,103 ms
コンパイル使用メモリ 204,216 KB
実行使用メモリ 24,012 KB
平均クエリ数 56.90
最終ジャッジ日時 2024-01-11 01:13:03
合計ジャッジ時間 4,473 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  cout<<"? "<<1<<" "<<n<<endl;
  int sum;
  cin>>sum;
  vector<int> ANS(n+1);
  vector<int> A(n+1,1);
  A[0]=0;
  for(int i=n-1;i>=2;i--){
    cout<<"? "<<1<<" "<<i<<endl;
    int a;
    cin>>a;
    ANS[i+1]=sum-a;
    A[sum-a]=0;
  }
  cout<<"? "<<2<<" "<<n<<endl;
  int a;
  cin>>a;
  ANS[1]=sum-a;
  A[sum-a]=0;
  rep(i,n+1){
    if(A[i]) ANS[2]=i; 
  }
  cout<<'!';
  for(int i=1;i<=n;i++) cout<<" "<<ANS[i];
  cout<<endl;
    
  return 0;
}
0