Submission #1064899

#TimeUsernameProblemLanguageResultExecution timeMemory
1064899DeathIsAweSecret (JOI14_secret)C++14
0 / 100
322 ms12216 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; int bollocks[1000][1000], divider[129], conquer[1000][1000], arr[1000], en; bool exist[1000]; void bollocksolve(int x, int y) { for (int i=x;i<=y;i++) { bollocks[i][i] = arr[i]; for (int j=i+1;j<=y;j++) { bollocks[i][j] = Secret(bollocks[i][j - 1], arr[j]); } } } void solve(int x, int y, int depth) { int mid = (x + y) / 2; exist[mid] = true; conquer[mid][mid] = arr[mid]; conquer[mid + 1][mid] = arr[mid + 1]; for (int i = mid - 1; i >= x; i--) { conquer[i][mid] = Secret(arr[i], conquer[i + 1][mid]); } for (int i = mid + 2; i <= y; i++) { conquer[i][mid] = Secret(conquer[i - 1][mid], arr[i]); } if (depth < 7) { if (x < mid) { solve(x, mid, depth + 1); } if (y > mid + 1) { solve(mid + 1, y, depth + 1); } } else { if (x < mid) { bollocksolve(x, mid); } if (y > mid + 1) { bollocksolve(mid + 1, y); } } } void Init(int n, int a[]) { en = n; for (int i=0;i<n;i++) { arr[i] = a[i]; exist[i] = false; } solve(0, n - 1, 1); } int Query(int L, int R) { int top = en - 1, bottom = 0, mid; while (true) { mid = (top + bottom) / 2; if (L > mid) { bottom = mid; } else if (R < mid) { top = mid; } else { break; } } //cout << mid << ' ' << exist[mid] << ' '; if (exist[mid]) { if (L == mid) { return conquer[R][L]; } else if (R == mid) { return conquer[L][R]; } //cout << conquer[L][mid] << ' ' << conquer[R][mid] << ' '; return Secret(conquer[L][mid], conquer[R][mid]); } else { return bollocks[L][R]; } }
#Verdict Execution timeMemoryGrader output
Fetching results...