結果
問題 | No.2978 Lexicographically Smallest and Largest Subarray |
ユーザー | Astral__ |
提出日時 | 2024-12-11 09:50:40 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,804 bytes |
コンパイル時間 | 5,659 ms |
コンパイル使用メモリ | 311,168 KB |
実行使用メモリ | 25,592 KB |
平均クエリ数 | 1499.00 |
最終ジャッジ日時 | 2024-12-11 09:51:01 |
合計ジャッジ時間 | 20,297 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 176 ms
25,196 KB |
testcase_01 | AC | 173 ms
24,812 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 177 ms
24,824 KB |
testcase_08 | AC | 193 ms
24,824 KB |
testcase_09 | AC | 173 ms
25,208 KB |
testcase_10 | AC | 171 ms
24,568 KB |
testcase_11 | AC | 174 ms
24,824 KB |
testcase_12 | AC | 172 ms
25,208 KB |
testcase_13 | AC | 172 ms
24,824 KB |
testcase_14 | AC | 176 ms
24,824 KB |
testcase_15 | AC | 172 ms
24,568 KB |
testcase_16 | AC | 173 ms
24,568 KB |
testcase_17 | AC | 172 ms
25,208 KB |
testcase_18 | AC | 169 ms
24,824 KB |
testcase_19 | AC | 194 ms
25,208 KB |
testcase_20 | AC | 172 ms
24,568 KB |
testcase_21 | AC | 170 ms
24,952 KB |
testcase_22 | AC | 174 ms
25,208 KB |
testcase_23 | AC | 173 ms
25,464 KB |
testcase_24 | AC | 178 ms
25,208 KB |
testcase_25 | AC | 203 ms
24,952 KB |
testcase_26 | AC | 172 ms
24,824 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 172 ms
25,208 KB |
testcase_38 | AC | 171 ms
25,208 KB |
testcase_39 | AC | 169 ms
24,952 KB |
testcase_40 | AC | 169 ms
25,464 KB |
testcase_41 | AC | 170 ms
24,952 KB |
testcase_42 | AC | 171 ms
25,448 KB |
testcase_43 | AC | 172 ms
25,208 KB |
testcase_44 | WA | - |
testcase_45 | AC | 171 ms
25,208 KB |
testcase_46 | AC | 173 ms
25,092 KB |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | AC | 191 ms
25,220 KB |
testcase_50 | AC | 173 ms
25,220 KB |
testcase_51 | AC | 172 ms
25,220 KB |
testcase_52 | AC | 169 ms
24,964 KB |
testcase_53 | AC | 172 ms
24,836 KB |
testcase_54 | AC | 177 ms
24,964 KB |
testcase_55 | AC | 172 ms
24,836 KB |
testcase_56 | AC | 171 ms
24,580 KB |
ソースコード
#include <bits/stdc++.h> #if __has_include(<atcoder/all>) #include <atcoder/all> std::ostream &operator<<(std::ostream &os, const atcoder::modint998244353 &v) { os << v.val(); return os; } std::istream &operator>>(std::istream &is, atcoder::modint998244353 &v) { long long x; is >> x; v = x; return is; } std::ostream &operator<<(std::ostream &os, const atcoder::modint1000000007 &v) { os << v.val(); return os; } std::istream &operator>>(std::istream &is, atcoder::modint1000000007 &v) { long long x; is >> x; v = x; return is; } #endif using namespace std; using ll = long long; using pll = pair<ll, ll>; #define el '\n'; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define rrep(i, s, t) for (ll i = (ll)(t) - 1; i >= (ll)(s); i--) #define all(x) begin(x), end(x) #define eb emplace_back #define pb push_back #define TT template <typename T> TT using vec = vector<T>; TT using vvec = vec<vec<T>>; TT using vvvec = vec<vvec<T>>; TT using minheap = priority_queue<T, vector<T>, greater<T>>; TT using maxheap = priority_queue<T>; TT bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; } TT bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; } TT bool rng(T l, T x, T r) { return l <= x && x < r; } TT T flr(T a, T b) { if (b < 0) a = -a, b = -b; return a >= 0 ? a / b : (a + 1) / b - 1; } TT T cil(T a, T b) { if (b < 0) a = -a, b = -b; return a > 0 ? (a - 1) / b + 1 : a / b; } TT T sqr(T x) { return x * x; } struct io_setup { io_setup() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(15); } } io_setup; template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << " " << p.second; return os; } TT ostream &operator<<(ostream &os, const vec<T> &v) { for (size_t i = 0; i < v.size(); i++) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } template <typename T, ll n> ostream &operator<<(ostream &os, const array<T, n> &v) { for (size_t i = 0; i < n; i++) { os << v[i] << (i + 1 != n ? " " : ""); } return os; } template <typename T> ostream &operator<<(ostream &os, const vvec<T> &v) { for (size_t i = 0; i < v.size(); i++) { os << v[i] << (i + 1 != v.size() ? "\n" : ""); } return os; } TT istream &operator>>(istream &is, vec<T> &v) { for (size_t i = 0; i < v.size(); i++) { is >> v[i]; } return is; } #if __has_include(<debug/debug.hpp>) #include <debug/debug.hpp> #else #define dbg(...) true #define DBG(...) true #define OUT(...) true #endif template <typename T, long long mod> struct combination { vector<long long> fac, ifac, inv; long long N; combination() { fac.resize(2, 1); ifac.resize(2, 1); inv.resize(2, 1); N = 1; } void reserve(long long n) { expand(n); } T operator()(int n, int k) { return C(n, k); } T C(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; if (N < n) expand(n); return fac[n] * ifac[n - k] % mod * ifac[k] % mod; } T P(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; if (N < n) expand(n); return fac[n] * ifac[n - k] % mod; } T B(int n) { if (N < n) expand(n); return (n < 0 ? 0 : fac[n]); } T invB(int n) { if (N < n) expand(n); return (n < 0 ? 0 : ifac[n]); } T H(int n, int k) { return C(n + k - 1, k); } T Cn(int n) { return C(2 * n, n) * inv[n + 1] % mod; } private: constexpr static bool is_prime_constexpr(long long x) { if (x <= 1) return false; for (long long i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } static_assert(is_prime_constexpr(mod), "mod must be prime"); long long extgcd(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1; y = 0; return a; } auto d = extgcd(b, a % b, y, x); y -= a / b * x; return d; } long long modinv(long long a) { long long x, y; extgcd(a, mod, x, y); x %= mod; if (x < 0) x += mod; return x; } void expand(long long new_max_n) { if (new_max_n <= N) return; long long nx = N; // 2冪で大きくしていく。 while (nx < new_max_n) nx <<= 1; new_max_n = nx; long long pre = N; N = new_max_n; fac.resize(N + 1); ifac.resize(N + 1); inv.resize(N + 1); for (long long i = pre + 1; i <= N; i++) { fac[i] = fac[i - 1] * i % mod; } ifac[N] = modinv(fac[N]); inv[N] = ifac[N] * fac[N - 1] % mod; for (long long i = N - 1; i >= pre + 1; i--) { ifac[i] = ifac[i + 1] * (i + 1) % mod; inv[i] = ifac[i] * fac[i - 1] % mod; } return; } }; using combination998244353 = combination<atcoder::modint998244353, 998244353>; using mint = atcoder::modint998244353; int main() { ll n, q; cin >> n >> q; vec<ll> B = {2, 4, 1, 3}; ll c = 0; auto cmp = [&](ll i, ll j) { assert(c != q); c++; dbg(B[i - 1], B[j - 1]); cout << "? " << i << " " << i << " " << j << " " << j << endl; int ret; cin >> ret; return ret == 1; }; vec<ll> A(n); iota(all(A), 1); auto ans = minmax_element(all(A), cmp); int i1 = *ans.first;// - A.begin(); int i2 = *ans.second;// - A.begin(); cout << "! " << i1 << " " << i1 << " " << i2 << " " << n << endl; } // 2 4 1 3