# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
95288 |
2019-01-29T15:07:48 Z |
dalgerok |
Secret (JOI14_secret) |
C++14 |
|
507 ms |
9504 KB |
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, a[N], dp[N][N];
bool used[N][N];
void rec(int l, int r){
if(l == r){
return;
}
if(l + 1 == r){
return;
}
int mid = (r + l) >> 1;
dp[mid][mid] = a[mid];
dp[mid + 1][mid + 1] = a[mid + 1];
for(int i = mid + 2; i <= r; i++){
if(!used[mid + 1][i]){
used[mid + 1][i] = true;
dp[mid + 1][i] = Secret(dp[mid + 1][i - 1], a[i]);
}
}
for(int i = mid - 1; i >= l; i--){
if(!used[i][mid]){
used[i][mid] = true;
dp[i][mid] = Secret(a[i], dp[i + 1][mid]);
}
}
rec(l, mid);
rec(mid + 1, r);
}
void Init(int N, int A[]){
n = N;
for(int i = 0; i < n; i++){
a[i] = A[i];
}
rec(0, n - 1);
}
int Query(int L, int R){
if(L == R){
return a[L];
}
if(L + 1 == R){
return Secret(a[L], a[R]);
}
int l = 0, r = n - 1;
while(r - l > 1){
int mid = (r + l) >> 1;
if(L <= mid && mid + 1 <= R){
return Secret(dp[L][mid], dp[mid + 1][R]);
}
if(R <= mid){
r = mid;
}
else{
l = mid + 1;
}
}
}
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
145 ms |
4964 KB |
Output is correct - number of calls to Secret by Init = 3084, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
148 ms |
4984 KB |
Output is correct - number of calls to Secret by Init = 3092, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
146 ms |
5168 KB |
Output is correct - number of calls to Secret by Init = 3101, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
503 ms |
9396 KB |
Output is correct - number of calls to Secret by Init = 6989, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
501 ms |
9336 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
504 ms |
9444 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
503 ms |
9504 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
504 ms |
9332 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
507 ms |
9336 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
505 ms |
9312 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |