結果
| 問題 | No.2124 Guess the Permutation |
| コンテスト | |
| ユーザー |
Rui
|
| 提出日時 | 2022-11-19 20:16:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 2,000 ms |
| コード長 | 1,267 bytes |
| コンパイル時間 | 3,898 ms |
| コンパイル使用メモリ | 235,556 KB |
| 実行使用メモリ | 25,220 KB |
| 平均クエリ数 | 374.60 |
| 最終ジャッジ日時 | 2024-09-21 02:00:51 |
| 合計ジャッジ時間 | 4,971 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
//typedef modint998244353 mint;
typedef modint1000000007 mint;
//const int MOD = 998244353;
const int MOD = 1000000007;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1 << 30;
const ll INF = 1LL << 60;
const int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
const int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
int main(){
int n;
cin >> n;
vector<int> ans(n);
int sum = (n + 1) * n / 2;
vector<int> r(n, 0);
rep(i, n - 2){
int a;
cout << "? " << i + 2 << ' ' << n << endl;
cin >> a;
ans[i] = sum - a - r[i];
r[i + 1] = r[i] + ans[i];
}
int a;
cout << "? " << 1 << ' ' << n - 1 << endl;
cin >> a;
ans[n - 1] = sum - a;
set<int> s;
rep(i, n) s.insert(i + 1);
rep(i, n) s.erase(ans[i]);
ans[n - 2] = *rbegin(s);
cout << "! ";
rep(i, n) cout << ans[i] << ' ';
cout << endl;
//4 3 5 1 2
return 0;
}
Rui