Submission #606165

# Submission time Handle Problem Language Result Execution time Memory
606165 2022-07-26T05:21:13 Z kawaii Secret (JOI14_secret) C++14
0 / 100
477 ms 8276 KB
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
 
int n, a[1005], pre[1005][1005];

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

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

int solve(int l, int r, int lf, int rt){
    if(l == r) return a[l];
    int mid = l + r >> 1;
    if(lf <= mid && mid <= rt){
        if(lf == mid) return pre[mid][rt];
        if(rt == mid) return pre[lf][mid];
        return Secret(pre[lf][mid], pre[mid + 1][rt]);
    }
    if(rt < mid) return solve(l, mid, lf, rt);
    else return solve(mid + 1, r, lf, rt);
}

int Query(int L, int R){
    L++; R++;
    return solve(1, n, L, R);
}

Compilation message

secret.cpp: In function 'void dnc(int, int)':
secret.cpp:9:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    9 |     int mid = l + r >> 1;
      |               ~~^~~
secret.cpp: In function 'int solve(int, int, int, int)':
secret.cpp:23:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |     int mid = l + r >> 1;
      |               ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 116 ms 4304 KB Wrong Answer: Query(255, 409) - expected : 307522235, actual : 0.
2 Incorrect 116 ms 4292 KB Wrong Answer: Query(127, 153) - expected : 342921603, actual : 0.
3 Incorrect 133 ms 4368 KB Wrong Answer: Query(128, 153) - expected : 959658850, actual : 0.
4 Incorrect 443 ms 8208 KB Wrong Answer: Query(374, 396) - expected : 402362963, actual : 0.
5 Incorrect 431 ms 8132 KB Wrong Answer: Query(703, 706) - expected : 857111674, actual : 0.
6 Incorrect 446 ms 8200 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 0.
7 Correct 477 ms 8140 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 434 ms 8276 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 475 ms 8176 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 463 ms 8160 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1