Submission #52551

#TimeUsernameProblemLanguageResultExecution timeMemory
52551suzySecret (JOI14_secret)C++14
0 / 100
2431 ms35856 KiB
#include "secret.h" #include <map> #include <utility> using namespace std; typedef pair<int, int> ip; int a[1001], n; map<ip, int> d; int qry(int l, int r, int L, int R) { if (L == R) return a[L]; int mid = (l + r) / 2; if (R < mid) return qry(l, mid, L, R); else if (L >= mid) return qry(mid, r, L, R); else return Secret(d[ip(L, mid - 1)], d[ip(mid, R)]); } int Query(int L, int R) { return qry(0, n, L, R); } void go(int l, int r) { if (l + 1 == r) return; int mid = (l + r) / 2; int cur = a[mid - 1]; for (int i = mid - 2; i >= 0; i--) { cur = Secret(cur, a[i]); d[ip(i, mid - 1)] = cur; } cur = a[mid]; for (int i = mid + 1; i < n; i++) { cur = Secret(cur, a[i]); d[ip(mid, i)] = cur; } go(l, mid); go(mid, r); } void Init(int N, int A[]) { n = N; for (int i = 0; i < n; i++) a[i] = A[i]; go(0, n); }
#Verdict Execution timeMemoryGrader output
Fetching results...