Submission #768149

# Submission time Handle Problem Language Result Execution time Memory
768149 2023-06-27T15:14:00 Z raysh07 Secret (JOI14_secret) C++17
0 / 100
401 ms 8308 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

int n;
const int maxn = 1001;
int a[maxn];
int ans[maxn][maxn];

void dnc(int l, int r){
    if (r <= l) return;
    int m = (l + r)/2;
    
    if (l != m) ans[m - 1][m] = Secret(a[m - 1], a[m]);
    for (int i = m - 2; i >= l; i--) ans[i][m] = Secret(ans[i + 1][m], a[i]);
    
    ans[m + 1][m + 1] = a[m + 1];
    for (int i = m + 2; i <= r; i++) ans[m + 1][i] = Secret(ans[m + 1][i - 1], a[i]);
    
    dnc(l, m - 1);
    dnc(m + 1, r);
}

void Init(int N, int A[]) {
    n = N;
    for (int i = 1; i <= n; i++) a[i] = A[i - 1];
    
    for (int i = 0; i < maxn; i++){
        for (int j = 0; j < maxn; j++){
            ans[i][j] = -1;
        }
    }
    
    dnc(1, n);
}

int Query(int l, int r) {
    l++;
    r++;
    
    if (l == r) return a[l];
    if (ans[l][r] != -1) return ans[l][r];
    
    for (int i = l + 1; i < r; i++){
        if (ans[l][i] != -1 && ans[i + 1][r] != -1) return Secret(ans[l][i], ans[i + 1][r]);
    }
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 6348 KB Wrong Answer: Query(113, 206) - expected : 536899947, actual : 591735411.
2 Incorrect 104 ms 6316 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 982231080.
3 Incorrect 102 ms 6324 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 77934680.
4 Incorrect 379 ms 8308 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 847954654.
5 Incorrect 374 ms 8268 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 737303816.
6 Incorrect 379 ms 8264 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 311087289.
7 Incorrect 376 ms 8268 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 711465992.
8 Incorrect 385 ms 8280 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 674537680.
9 Incorrect 376 ms 8200 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 970730735.
10 Incorrect 401 ms 8196 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 69509196.