Submission #877479

# Submission time Handle Problem Language Result Execution time Memory
877479 2023-11-23T09:19:08 Z serkanrashid Secret (JOI14_secret) C++14
0 / 100
384 ms 4528 KB
#include "secret.h"
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1024;

int n,a[maxn];
int pref[maxn][16],suff[maxn][16];
int idx;

void query(int l, int r, int lvl, int L, int R)
{
    int mid = (l+r)/2;
    if(L<=mid&&mid<=R)
    {
        idx = lvl;
        return;
    }
    if(R<mid) query(l,mid+0,lvl+1,L,R);
    else query(mid+1,r,lvl+1,L,R);
}

int Query(int L, int R)
{
    L++;
    R++;
    idx = 0;
    query(1,n,1,L,R);
    int ans = pref[L][idx];
    if(L!=R) ans = Secret(ans,suff[R][idx]);
    return ans;
}

void divide(int l, int r, int lvl)
{
    int mid = (l+r)/2;
    pref[mid][lvl] = a[mid];
    for(int i=mid-1;i>=l;i--) pref[i][lvl] = Secret(a[i],pref[i+1][lvl]);
    if(mid!=r) suff[mid+1][lvl] = a[mid+1];
    for(int i=mid+2;i<=r;i++) suff[i][lvl] = Secret(suff[i-1][lvl],a[i]);
    if(l==r) return;
    divide(l,mid+0,lvl+1);
    divide(mid+1,r,lvl+1);
}

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

/*int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

return 0;
}*/
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 2652 KB Wrong Answer: Query(264, 271) - expected : 675707686, actual : 4619042.
2 Incorrect 100 ms 2728 KB Wrong Answer: Query(210, 211) - expected : 558550312, actual : 558532904.
3 Incorrect 100 ms 2732 KB Wrong Answer: Query(64, 128) - expected : 469502, actual : 537340286.
4 Incorrect 375 ms 4412 KB Wrong Answer: Query(571, 624) - expected : 309502044, actual : 309493852.
5 Incorrect 371 ms 4524 KB Wrong Answer: Query(876, 890) - expected : 899551822, actual : 362418254.
6 Incorrect 382 ms 4328 KB Wrong Answer: Query(747, 749) - expected : 244228265, actual : 143302825.
7 Correct 378 ms 4520 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 383 ms 4528 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 380 ms 4432 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 384 ms 4524 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1