Submission #751916

#TimeUsernameProblemLanguageResultExecution timeMemory
751916Markomafko972Secret (JOI14_secret)C++14
100 / 100
487 ms12132 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; int val[1005][1005]; int sus[1005][1005]; void rek(int l, int r) { if (l >= r) return; int mid = (l+r)/2; for (int i = l; i <= mid; i++) { for (int j = mid+1; j <= r; j++) { sus[i][j] = mid; } } for (int j = mid-1; j >= l; j--) val[j][mid] = Secret(val[j][j], val[j+1][mid]); for (int j = mid+2; j <= r; j++) val[mid+1][j] = Secret(val[mid+1][j-1], val[j][j]); rek(l, mid); rek(mid+1, r); } void Init(int N, int A[]) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i == j) val[i][j] = A[i]; else val[i][j] = -1; } } rek(0, N-1); } int Query(int L, int R) { if (val[L][R] != -1) return val[L][R]; return Secret(val[L][sus[L][R]], val[sus[L][R]+1][R]); }
#Verdict Execution timeMemoryGrader output
Fetching results...