# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
995272 |
2024-06-08T17:53:52 Z |
yeediot |
Secret (JOI14_secret) |
C++17 |
|
323 ms |
4492 KB |
#include<bits/stdc++.h>
#include "secret.h"
//#include "/Users/iantsai/Downloads/secret/grader.cpp"
using namespace std;
const int mxn = 1005;
int seg[4*mxn], a[mxn], n, v[15][mxn];
void build(int l,int r,int id){
if(l == r){
return;
}
int mm = l+r>>1;
v[id][mm] = a[mm];
v[id][mm+1] = a[mm+1];
for(int i=mm-1;i>=l;i--){
v[id][i] = Secret(a[i], v[id][i+1]);
}
for(int i=mm+2;i<=r;i++){
v[id][i] = Secret(v[id][i-1], a[i]);
}
build(l, mm, id+1);
build(mm+1, r, id+1);
}
int query(int l,int r, int id,int ql,int qr){
if(l==r){
return a[l];
}
int mm=l+r>>1;
if(qr<=mm){
return query(l,mm,id+1,ql,qr);
}
else if(ql>mm){
return query(mm+1,r,id+1,ql,qr);
}
else{
return Secret(v[id][ql],v[id][qr]);
}
}
void Init(int N, int b[]){
n = N;
for(int i=1;i<=n;i++){
a[i] = b[i-1];
}
build(1,n,1);
}
int Query(int l,int r){
l++;
r++;
return query(1,n,1,l,r);
}
Compilation message
secret.cpp: In function 'void build(int, int, int)':
secret.cpp:11:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
11 | int mm = l+r>>1;
| ~^~
secret.cpp: In function 'int query(int, int, int, int, int)':
secret.cpp:27:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
27 | int mm=l+r>>1;
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
2652 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
85 ms |
2652 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
85 ms |
2744 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
308 ms |
4432 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
323 ms |
4268 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
310 ms |
4264 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
312 ms |
4492 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
320 ms |
4268 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
317 ms |
4284 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
310 ms |
4268 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |