# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
320388 |
2020-11-08T13:41:48 Z |
ryangohca |
Secret (JOI14_secret) |
C++17 |
|
537 ms |
8548 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> nums;
int stored[1001][1001];
void dnc(int l, int r){
if (l == r) return;
if (r - l == 1){
if (stored[l][r] != -1) return;
stored[l][r] = Secret(nums[l], nums[r]);
return;
}
int mid = (l + r) / 2;
int accum = (stored[mid - 1][mid] == -1 ? Secret(nums[mid - 1], nums[mid]) : stored[mid - 1][mid]);
stored[mid - 1][mid] = accum;
for (int i = mid - 2; i >= l; i--){
if (stored[i][mid] != -1) accum = stored[i][mid];
else stored[i][mid] = accum = Secret(nums[i], accum);
}
accum = (stored[mid][mid + 1] == -1 ? Secret(nums[mid], nums[mid + 1]) : stored[mid][mid + 1]);
stored[mid][mid + 1] = accum;
for (int i = mid + 2; i <= r; i++){
if (stored[mid][i] != -1) accum = stored[mid][i];
else stored[mid][i] = accum = Secret(accum, nums[i]);
}
dnc(l, mid);
dnc(mid + 1, r);
}
void Init(int N, int A[]) {
memset(stored, -1, sizeof stored);
for (int i = 0; i < N; i++){
nums.push_back(A[i]);
stored[i][i] = A[i];
}
dnc(0, N - 1);
}
int Query(int L, int R) {
if (L == R) return nums[L];
if (R - L == 1) return Secret(nums[L], nums[R]);
for (int i = L; i < R; i++){
if (stored[L][i] != -1 && stored[i + 1][R] != -1) return Secret(stored[L][i], stored[i + 1][R]);
}
return stored[L][R];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
135 ms |
6392 KB |
Wrong Answer: Query(113, 206) - expected : 536899947, actual : -1. |
2 |
Incorrect |
133 ms |
6372 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : -1. |
3 |
Incorrect |
137 ms |
6416 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : -1. |
4 |
Incorrect |
537 ms |
8332 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : -1. |
5 |
Incorrect |
504 ms |
8292 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : -1. |
6 |
Incorrect |
499 ms |
8304 KB |
Wrong Answer: Query(200, 208) - expected : 277813445, actual : -1. |
7 |
Incorrect |
500 ms |
8292 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : -1. |
8 |
Incorrect |
496 ms |
8548 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : -1. |
9 |
Incorrect |
500 ms |
8376 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : -1. |
10 |
Incorrect |
501 ms |
8292 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : -1. |