제출 #247426

#제출 시각아이디문제언어결과실행 시간메모리
247426receed비밀 (JOI14_secret)C++14
100 / 100
530 ms4424 KiB
#include "secret.h" #include <iostream> #include <iomanip> #include <cstdio> #include <vector> #include <algorithm> #include <cmath> #include <cstring> #include <cassert> #include <string> #include <set> #include <map> #include <random> #include <bitset> #include <string> #include <unordered_set> #include <unordered_map> #include <deque> #include <queue> #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() using namespace std; using ll = long long; using ul = unsigned long long; using ld = long double; const int N = 1000, L = 10; int d[L][N + 1]; void Init(int n, int a[]) { for (int i = 0; (1 << i) <= n; i++) { int pw = 1 << i; for (int j = pw; j <= n; j += pw * 2) { d[i][j - 1] = a[j - 1]; if (j < n) d[i][j] = a[j]; for (int k = j - 2; k >= j - pw; k--) d[i][k] = Secret(a[k], d[i][k + 1]); for (int k = j + 1; k < min(n, j + pw); k++) d[i][k] = Secret(d[i][k - 1], a[k]); } } } int Query(int l, int r) { if (l == r) return d[0][l]; int x = l ^ r, pos = 0; while ((2 << pos) <= x) pos++; return Secret(d[pos][l], d[pos][r]); }
#Verdict Execution timeMemoryGrader output
Fetching results...