Submission #54642

# Submission time Handle Problem Language Result Execution time Memory
54642 2018-07-04T10:49:58 Z gs18115 Secret (JOI14_secret) C++14
0 / 100
728 ms 7548 KB
#include"secret.h"
#include<map>
using namespace std;
map<pair<int,int>,bool>CHK;
map<pair<int,int>,int>SEC;
int ST[4567];
int N2;
int Secret2(int X,int Y)
{
    pair<int,int>P;
    P=make_pair(X,Y);
    if(CHK[P])
        return SEC[P];
    CHK[P]=true;
    return SEC[P]=Secret(X,Y);
}
void P(int I,int N)
{
    if(I==1)
        return;
    ST[I]=N;
    if(I&1)
        P(I>>1,Secret2(ST[I^1],N));
    else
        P(I>>1,Secret2(N,ST[I^1]));
}
int Q(int S,int F)
{
    if(S>F)return 0;
    int A;
    A=Q(S+1>>1,F-1>>1);
    if(S&1)
        A=Secret2(ST[S],A);
    if(!(F&1))
        A=Secret2(A,ST[F]);
    return A;
}
void Init(int N,int A[])
{
    for(N2=1;N2<N;N2<<=1);
    for(int i=0;i<N;i++)
        P(i+N2,A[i]);
}
int Query(int L,int R)
{
    return Q(L+N2,R+N2);
}

Compilation message

secret.cpp: In function 'int Q(int, int)':
secret.cpp:31:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     A=Q(S+1>>1,F-1>>1);
         ~^~
secret.cpp:31:17: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
     A=Q(S+1>>1,F-1>>1);
                ~^~
# Verdict Execution time Memory Grader output
1 Incorrect 187 ms 2816 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 34031537.
2 Incorrect 165 ms 2980 KB Wrong Answer: Query(102, 157) - expected : 32612619, actual : 569483529.
3 Incorrect 170 ms 3120 KB Wrong Answer: Query(67, 224) - expected : 202440844, actual : 739311628.
4 Incorrect 593 ms 5604 KB Wrong Answer: Query(727, 872) - expected : 870334875, actual : 870334619.
5 Incorrect 599 ms 5680 KB Wrong Answer: Query(761, 790) - expected : 112945480, actual : 112871752.
6 Incorrect 611 ms 5756 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 278446241.
7 Incorrect 726 ms 7152 KB Output isn't correct - number of calls to Secret by Init = 8203, maximum number of calls to Secret by Query = 11
8 Incorrect 650 ms 7524 KB Output isn't correct - number of calls to Secret by Init = 8196, maximum number of calls to Secret by Query = 11
9 Incorrect 647 ms 7524 KB Output isn't correct - number of calls to Secret by Init = 8191, maximum number of calls to Secret by Query = 12
10 Incorrect 728 ms 7548 KB Output isn't correct - number of calls to Secret by Init = 8211, maximum number of calls to Secret by Query = 11