結果

問題 No.2124 Guess the Permutation
ユーザー umezo
提出日時 2024-01-11 01:18:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 651 bytes
コンパイル時間 2,253 ms
コンパイル使用メモリ 194,768 KB
最終ジャッジ日時 2025-02-18 17:06:09
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 WA * 4 RE * 4
権限があれば一括ダウンロードができます

ソースコード

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;
  int sum=n*(n+1)/2;
  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