結果

問題 No.2124 Guess the Permutation
ユーザー Gorin2006Gorin2006
提出日時 2022-12-05 17:29:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 1,316 bytes
コンパイル時間 1,753 ms
コンパイル使用メモリ 164,516 KB
実行使用メモリ 25,604 KB
平均クエリ数 374.60
最終ジャッジ日時 2024-04-20 17:59:01
合計ジャッジ時間 3,123 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//using mint2 = modint998244353;
typedef long long ll;
#define rep1(i, m, n) for(int i = m; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i <= (int)(n); i++)
#define all(x) x.begin(), x.end()
#define rall(x) xkkkk.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if(a < b) {a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if(a > b) {a = b; return true; } return false; }
const ll INF = 1LL << 60;
//#define _GLIBCXX_DEBUG
// 範囲外エラーを教えてくれる。使うときはincludeより上に置く。

// const char newl='\n';

int main() {
  int n; cin >> n;
  vector<int> s(n);
  vector<int> p(n);
  s[0]=n*(n+1);
  s[0]/=2;
  cout << '?' << " " << 2 << " " << n << endl << flush;
  int a; cin >> a;
  p[0]=s[0]-a;
  for (int i=1; i<n-1; i++) {
    cout << '?' << " " << i << " " << i+1 << endl << flush;
    int t=0; cin >> t;
    p[i]=t-p[i-1];
  }
  for (int i=0; i<n-1; i++) s[i+1]=s[i]-p[i];
  p[n-1]=s[n-1];
  cout << '!' << " ";
  for (int i=0; i<n; i++) cout << p[i] << " ";
  cout << endl;
  system("pause");
}
0