結果

問題 No.2124 Guess the Permutation
ユーザー umezoumezo
提出日時 2024-01-11 01:21:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 685 bytes
コンパイル時間 2,979 ms
コンパイル使用メモリ 204,080 KB
実行使用メモリ 24,012 KB
平均クエリ数 374.60
最終ジャッジ日時 2024-01-11 01:21:19
合計ジャッジ時間 3,570 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
  int tmp=sum;
  for(int i=n-1;i>=2;i--){
    cout<<"? "<<1<<" "<<i<<endl;
    int a;
    cin>>a;
    ANS[i+1]=tmp-a;
    A[tmp-a]=0;
    tmp-=ANS[i+1];
  }
  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