Submission #877511

# Submission time Handle Problem Language Result Execution time Memory
877511 2023-11-23T09:30:06 Z Ivkosqn Secret (JOI14_secret) C++14
0 / 100
355 ms 11860 KB
#include <bits/stdc++.h>
#include "secret.h"
#define endl '\n'

using namespace std;

const int maxn = 1024;
int pref[maxn][maxn], suff[maxn][maxn];
int lf[maxn], rg[maxn], a[maxn];
vector<int> mids;

void divide(int l, int r){
    if(l > r)
        return;
    if(l == r){
        suff[l][l] = a[l];
        lf[l] = l;
        rg[l] = l;
        mids.push_back(l);
        return;
    }
    int mid = (l + r) / 2;
    mids.push_back(mid);
    divide(l, mid - 1);
    divide(mid + 1, r);
    lf[mid] = l, rg[mid] = r;
    suff[mid][l] = a[l];
    pref[mid][mid + 1] = a[mid + 1];
    for(int i = l + 1;i <= mid;i++)
        suff[mid][i] = Secret(suff[mid][i - 1], a[i]);
    for(int i = mid + 2;i <= r;i++)
        pref[mid][i] = Secret(pref[mid][i - 1], a[i]);
}

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

int Query(int l, int r){
    for(int x : mids){
        if(lf[x] <= l && rg[x] >= r && x >= l && x <= r){
            int ans = suff[x][l];
            if(x != r)
                ans = Secret(ans, pref[x][r]);
            return ans;
        }
    }
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
   50 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 10832 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 843388599.
2 Incorrect 95 ms 10836 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 344699176.
3 Incorrect 94 ms 10856 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 69362004.
4 Incorrect 349 ms 11608 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 603029557.
5 Incorrect 349 ms 11596 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 603081984.
6 Incorrect 355 ms 11860 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 321775817.
7 Incorrect 349 ms 11604 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 623902835.
8 Incorrect 350 ms 11608 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 67262608.
9 Incorrect 349 ms 11600 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 404497100.
10 Incorrect 351 ms 11600 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 603982414.