# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
605830 |
2022-07-26T03:12:11 Z |
socpite |
Secret (JOI14_secret) |
C++14 |
|
20000 ms |
8388 KB |
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
const int maxn = 1005;
int pfx[4*maxn][maxn], sfx[4*maxn][maxn];
int arr[maxn];
int n;
void build(int l, int r, int id){
if(r-l<=1)return;
int mid = (l+r)>>1;
pfx[id][0]=arr[mid+1];
sfx[id][0]=arr[mid];
for(int i = mid+2; i <= r; i++){
pfx[id][i-mid-1]=Secret(pfx[id][i-mid-2], arr[i]);
}
for(int i = 1; i < mid+1-l; i++){
sfx[id][i]=Secret(arr[mid-i], sfx[id][i-1]);
}
build(l, mid, id<<1);
build(mid+1, r, id<<1|1);
}
int gt(int l, int r, int ql, int qr, int id){
int mid = (l+r)>>1;
if(qr < mid)return gt(l, r, ql, qr, id<<1);
else if(ql > mid+1)return gt(mid+1, r, ql, qr, id<<1|1);
else{
int re = -1;
if(ql <= mid)re = sfx[id][mid-ql];
if(qr >= mid+1){
if(re < 0)re = pfx[id][qr-mid-1];
else re = Secret(re, pfx[id][qr-mid-1]);
}
return re;
}
}
int Query(int L, int R){
if(L==R)return arr[L];
else if(R-1==L)return Secret(arr[L], arr[R]);
else return gt(0, n-1, L, R, 1);
}
void Init(int N, int A[]){
n = N;
for(int i = 0; i < n; i++)arr[i]=A[i];
build(0, n-1, 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
20057 ms |
4300 KB |
Time limit exceeded |
2 |
Execution timed out |
20050 ms |
4300 KB |
Time limit exceeded |
3 |
Execution timed out |
20091 ms |
4352 KB |
Time limit exceeded |
4 |
Execution timed out |
20089 ms |
8224 KB |
Time limit exceeded |
5 |
Execution timed out |
20090 ms |
8188 KB |
Time limit exceeded |
6 |
Execution timed out |
20085 ms |
8272 KB |
Time limit exceeded |
7 |
Correct |
424 ms |
8268 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
439 ms |
8252 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
445 ms |
8388 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
432 ms |
8348 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |