Submission #320389

# Submission time Handle Problem Language Result Execution time Memory
320389 2020-11-08T13:46:34 Z ryangohca Secret (JOI14_secret) C++17
0 / 100
522 ms 8324 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, 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 136 ms 6372 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 155 ms 6376 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : -1.
4 Incorrect 498 ms 8292 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : -1.
5 Incorrect 522 ms 8292 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : -1.
6 Incorrect 509 ms 8292 KB Wrong Answer: Query(20, 28) - expected : 304983587, actual : -1.
7 Incorrect 503 ms 8324 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : -1.
8 Incorrect 518 ms 8188 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : -1.
9 Incorrect 513 ms 8292 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : -1.
10 Incorrect 495 ms 8292 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : -1.