# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
255879 |
2020-08-02T03:28:33 Z |
IOrtroiii |
Secret (JOI14_secret) |
C++14 |
|
520 ms |
8460 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
int A[1010];
int dp[1010][1010];
void gen(int l, int r) {
if (l == r) {
dp[l][r] = A[l];
return;
}
int md = (l + r) >> 1;
gen(l, md);
gen(md + 1, r);
for (int i = md - 1; i >= l; --i) dp[i][md] = Secret(A[i], dp[i + 1][md]);
for (int i = md + 2; i <= r; ++i) dp[md + 1][i] = Secret(dp[md + 1][i - 1], A[i]);
}
void Init(int N, int _A[]) {
for (int i = 0; i < N; ++i) A[i] = _A[i];
memset(dp, -1, sizeof dp);
gen(0, N - 1);
}
int Query(int l, int r) {
if (l == r) return A[l];
for (int md = l; md < r; ++md) {
if (dp[l][md] >= 0 && dp[md + 1][r] >= 0) {
return Secret(dp[l][md], dp[md + 1][r]);
}
}
}
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
153 ms |
6392 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
158 ms |
6520 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
151 ms |
6392 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
520 ms |
8440 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
508 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
506 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
517 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
512 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
515 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
513 ms |
8460 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |