# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
54659 |
2018-07-04T11:32:45 Z |
gs18115 |
Secret (JOI14_secret) |
C++14 |
|
667 ms |
7608 KB |
#include"secret.h"
#include<unordered_map>
using namespace std;
unordered_map<unsigned long long,bool>CHK;
unordered_map<unsigned long long,int>SEC;
int ST[4567];
int N2;
int Secret2(int X,int Y)
{
unsigned long long P;
P=X;
P<<=32;
P|=Y;
if(CHK[P])
return SEC[P];
CHK[P]=true;
return SEC[P]=Secret(X,Y);
}
void P(int I,int N)
{
ST[I]=N;
if(I==1)
return;
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 ST[S];
else if(S==F-1)
return Secret2(ST[S],ST[F]);
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++)
ST[i+N2]=A[i];
for(int i=0;i<N+1>>1;i++)
P((i<<1)+N2,ST[(i<<1)+N2]);
int X=Q(0,N-2);
X=Q(1,N-1);
X=Q(0,N-1);
X=Q(1,N-2);
return;
}
int Query(int L,int R)
{
return Q(L+N2,R+N2);
}
Compilation message
secret.cpp: In function 'int Q(int, int)':
secret.cpp:36:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
A=Q(S+1>>1,F-1>>1);
~^~
secret.cpp:36:17: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
A=Q(S+1>>1,F-1>>1);
~^~
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:48:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
for(int i=0;i<N+1>>1;i++)
~^~
secret.cpp:50:9: warning: variable 'X' set but not used [-Wunused-but-set-variable]
int X=Q(0,N-2);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
211 ms |
4560 KB |
Output is partially correct - number of calls to Secret by Init = 1996, maximum number of calls to Secret by Query = 9 |
2 |
Partially correct |
207 ms |
4700 KB |
Output is partially correct - number of calls to Secret by Init = 1998, maximum number of calls to Secret by Query = 10 |
3 |
Partially correct |
211 ms |
4700 KB |
Output is partially correct - number of calls to Secret by Init = 2114, maximum number of calls to Secret by Query = 11 |
4 |
Partially correct |
667 ms |
7608 KB |
Output is partially correct - number of calls to Secret by Init = 4238, maximum number of calls to Secret by Query = 12 |
5 |
Partially correct |
659 ms |
7608 KB |
Output is partially correct - number of calls to Secret by Init = 4235, maximum number of calls to Secret by Query = 12 |
6 |
Partially correct |
609 ms |
7608 KB |
Output is partially correct - number of calls to Secret by Init = 4248, maximum number of calls to Secret by Query = 4 |
7 |
Partially correct |
642 ms |
7608 KB |
Output is partially correct - number of calls to Secret by Init = 4249, maximum number of calls to Secret by Query = 11 |
8 |
Partially correct |
626 ms |
7608 KB |
Output is partially correct - number of calls to Secret by Init = 4242, maximum number of calls to Secret by Query = 10 |
9 |
Partially correct |
655 ms |
7608 KB |
Output is partially correct - number of calls to Secret by Init = 4240, maximum number of calls to Secret by Query = 11 |
10 |
Partially correct |
619 ms |
7608 KB |
Output is partially correct - number of calls to Secret by Init = 4256, maximum number of calls to Secret by Query = 11 |