# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
54651 |
2018-07-04T11:05:03 Z |
red1108 |
Secret (JOI14_secret) |
C++17 |
|
738 ms |
4704 KB |
#include <stdio.h>
#include <algorithm>
#include "secret.h"
using namespace std;
int seg[10000], si=1;
void Init(int N, int A[])
{
int input[2000],i;
while(si<N) si*=2;
for(i=N;i>=1;i--)
{
input[i]=A[i-1];
}
for(i=1;i<=si*4;i++) seg[i]=123456789;
for(i=si+N-1;i>=si;i--)
{
seg[i]=input[i-si+1];
}
for(i=si-1;i>=1;i--)
{
if(seg[i*2]==123456789)seg[i]=123456789;
else if(seg[i*2+1]==123456789)seg[i]=seg[i*2];
else seg[i]=Secret(seg[i*2],seg[i*2+1]);
}
}
int query(int x, int l, int r, int s, int e)
{
int mid, left, right;
if(r<s||l>e||l>r) return 123456789;
if(s<=l&&r<=e) return seg[x];
left=query(x*2, l,(l+r)/2,s,e);
right=query(x*2+1, ((l+r)/2)+1,r, s, e);
if(left==123456789&&right==123456789) return 123456789;
else if(right==123456789) return left;
else if(left==123456789) return right;
else return Secret(left, right);
}
int Query(int L, int R)
{
L++;
R++;
return query(1,1,si,L, R);
}
Compilation message
secret.cpp: In function 'int query(int, int, int, int, int)':
secret.cpp:29:9: warning: unused variable 'mid' [-Wunused-variable]
int mid, left, right;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
234 ms |
2472 KB |
Output is partially correct - number of calls to Secret by Init = 510, maximum number of calls to Secret by Query = 14 |
2 |
Partially correct |
249 ms |
2488 KB |
Output is partially correct - number of calls to Secret by Init = 511, maximum number of calls to Secret by Query = 14 |
3 |
Partially correct |
230 ms |
2488 KB |
Output is partially correct - number of calls to Secret by Init = 512, maximum number of calls to Secret by Query = 14 |
4 |
Partially correct |
698 ms |
4516 KB |
Output is partially correct - number of calls to Secret by Init = 998, maximum number of calls to Secret by Query = 15 |
5 |
Partially correct |
665 ms |
4548 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 14 |
6 |
Partially correct |
607 ms |
4556 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 4 |
7 |
Partially correct |
710 ms |
4556 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |
8 |
Partially correct |
738 ms |
4556 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |
9 |
Partially correct |
686 ms |
4688 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 15 |
10 |
Partially correct |
681 ms |
4704 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |