結果
問題 | No.2496 LCM between Permutations |
ユーザー | risujiroh |
提出日時 | 2023-10-06 22:08:14 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 4,020 bytes |
コンパイル時間 | 3,759 ms |
コンパイル使用メモリ | 272,052 KB |
実行使用メモリ | 27,820 KB |
平均クエリ数 | 646.90 |
最終ジャッジ日時 | 2024-07-26 16:12:34 |
合計ジャッジ時間 | 7,060 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | QLE | - |
testcase_04 | RE | - |
testcase_05 | WA | - |
testcase_06 | QLE | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | QLE | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
ソースコード
#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ namespace { void solve() { int n; cin >> n; auto query = [&](int i, int j) -> int { print('?', i, j); int x; cin >> x; return x; }; vector<pair<int, int>> pre(n * n + 1); for (int i : rep1(n)) { if (!atcoder::internal::is_prime_constexpr(i)) { continue; } for (int j : rep1(i, n)) { if (i * j <= n) { continue; } if (!atcoder::internal::is_prime_constexpr(j)) { continue; } pre[i * j] = {i, j}; } } while (true) { int i = randint(1, n); int j = randint(1, n); int x = query(i, j); vector<int> ans(n + n); if (pre[x].first) { for (int k : rep(n + n)) { if (k < n) { ans[k] = query(k + 1, j); } else { ans[k] = query(i, k - n + 1); } } for (int z : rep(2)) { auto rng = ans | views::drop(n * z) | views::take(n); int mn = ranges::min(rng); for (int& e : rng) { e /= mn; } } print('!', ans); return; } } } } // namespace int main() { ios::sync_with_stdio(false); solve(); } #else // __INCLUDE_LEVEL__ #include <bits/stdc++.h> using namespace std; #include <atcoder/internal_math> template <class T, class U = T> bool chmin(T& x, U&& y) { return y < x && (x = forward<U>(y), true); } template <class T, class U = T> bool chmax(T& x, U&& y) { return x < y && (x = forward<U>(y), true); } namespace std { template <class T1, class T2> istream& operator>>(istream& is, pair<T1, T2>& p) { return is >> p.first >> p.second; } template <class... Ts> istream& operator>>(istream& is, tuple<Ts...>& t) { return apply([&is](auto&... xs) -> istream& { return (is >> ... >> xs); }, t); } template <class... Ts> istream& operator>>(istream& is, tuple<Ts&...>&& t) { return is >> t; } template <class R, enable_if_t<!is_convertible_v<R, string>>* = nullptr> auto operator>>(istream& is, R&& r) -> decltype(is >> *begin(r)) { for (auto&& e : r) { is >> e; } return is; } template <class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << p.first << ' ' << p.second; } template <class... Ts> ostream& operator<<(ostream& os, const tuple<Ts...>& t) { auto f = [&os](const auto&... xs) -> ostream& { [[maybe_unused]] auto sep = ""; ((os << exchange(sep, " ") << xs), ...); return os; }; return apply(f, t); } template <class R, enable_if_t<!is_convertible_v<R, string_view>>* = nullptr> auto operator<<(ostream& os, R&& r) -> decltype(os << *begin(r)) { auto sep = ""; for (auto&& e : r) { os << exchange(sep, " ") << e; } return os; } } // namespace std template <class... Ts> void print(Ts&&... xs) { cout << tie(xs...) << '\n'; } inline mt19937_64 mt_engine( chrono::steady_clock::now().time_since_epoch().count()); template <bool Log = false> double uniform(double a, double b) { assert(a <= b); if constexpr (Log) { assert(0 < a); return exp(uniform(log(a), log(b))); } else { return uniform_real_distribution(a, b)(mt_engine); } } template <bool Log = false> int randint(int a, int b) { assert(a <= b); if constexpr (Log) { assert(0 < a); return round(uniform<true>(a - 0.5, b + 0.5)); } else { return uniform_int_distribution(a, b)(mt_engine); } } inline bool bernoulli(double p = 0.5) { assert(0 <= p && p <= 1); return bernoulli_distribution(p)(mt_engine); } inline auto rep(int l, int r) { return views::iota(min(l, r), r); } inline auto rep(int n) { return rep(0, n); } inline auto rep1(int l, int r) { return rep(l, r + 1); } inline auto rep1(int n) { return rep(1, n + 1); } inline auto per(int l, int r) { return rep(l, r) | views::reverse; } inline auto per(int n) { return per(0, n); } inline auto per1(int l, int r) { return per(l, r + 1); } inline auto per1(int n) { return per(1, n + 1); } inline auto len = ranges::ssize; #endif // __INCLUDE_LEVEL__