Submission #961042

#TimeUsernameProblemLanguageResultExecution timeMemory
961042PringSecret (JOI14_secret)C++17
100 / 100
458 ms5012 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; #ifdef MIKU string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m"; #define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x) void dout() { cout << dbrs << endl; } template <typename T, typename ...U> void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); } #else #define debug(...) 39 #endif #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++) using ll = long long; typedef pair<int, int> pii; namespace { const int MXN = 1005; int n, a[MXN], d[MXN]; map<pii, int> M; struct SMG { pii val[MXN * 2]; void build() { FOR(i, 0, n) val[i + n] = mp(d[i], i); for (int i = n - 1; i; i--) { val[i] = min(val[i << 1], val[(i << 1) | 1]); } } pii query(int l, int r) { pii x = mp(INT_MAX, -1); for (l += n, r += n; l < r; l >>= 1, r >>= 1) { if (l & 1) x = min(x, val[l++]); if (r & 1) x = min(x, val[--r]); } return x; } } smg; void SUF(int l, int r) { int x = a[r - 1]; for (int i = r - 2; i >= l; i--) { x = Secret(a[i], x); M[mp(i, r - 1)] = x; } } void PRE(int l, int r) { int x = a[l]; for (int i = l + 1; i < r; i++) { x = Secret(x, a[i]); M[mp(l, i)] = x; } } void build(int l, int r, int dep) { if (l + 1 == r) return; int mid = (l + r) >> 1; d[mid] = dep; SUF(l, mid); PRE(mid, r); build(l, mid, dep + 1); build(mid, r, dep + 1); } void init() { FOR(i, 0, n) M[mp(i, i)] = a[i]; build(0, n, 0); smg.build(); } int query(int l, int r) { if (l == r) return a[l]; int bnd = smg.query(l + 1, r + 1).sc; debug(bnd); return Secret(M[mp(l, bnd - 1)], M[mp(bnd, r)]); } } void Init(int N, int A[]) { ::n = N; FOR(i, 0, n) a[i] = A[i]; init(); } int Query(int l, int r) { return query(l, r); }

Compilation message (stderr)

secret.cpp: In function 'int {anonymous}::query(int, int)':
secret.cpp:12:20: warning: statement has no effect [-Wunused-value]
   12 | #define debug(...) 39
      |                    ^~
secret.cpp:79:3: note: in expansion of macro 'debug'
   79 |   debug(bnd);
      |   ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...