# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
380502 |
2021-03-22T05:30:13 Z |
pure_mem |
Secret (JOI14_secret) |
C++14 |
|
536 ms |
9492 KB |
#include "secret.h"
#include <bits/stdc++.h>
#define X first
#define Y second
#define MP make_pair
#define ll long long
using namespace std;
int q[1001][1001];
bool was[1001][1001];
void Init(int N, int A[]) {
stack< pair<int, int> > st;
st.push(MP(1, N));
while(!st.empty()){
int l = st.top().X, r = st.top().Y; st.pop();
int m = (l + r) / 2;
was[m][m] = 1, q[m][m] = A[m - 1];
for(int i = m - 1, j = A[m - 1];i >= l;i--){
j = Secret(A[i - 1], j), q[i][m] = j, was[i][m] = 1;
}
if(l == r)
continue;
was[m + 1][m + 1] = 1, q[m + 1][m + 1] = A[m];
for(int i = m + 2, j = A[m];i <= r;i++){
j = Secret(j, A[i - 1]), q[m + 1][i] = j, was[m + 1][i] = 1;
}
if(l != r)
st.push(MP(l, m)), st.push(MP(m + 1, r));
}
// Secret(0, 1000000000);
}
int Query(int L, int R) {
L += 1, R += 1;
if(was[L][R])
return q[L][R];
for(int i = L;i < R;i++){
if(was[L][i] && was[i + 1][R])
return Secret(q[L][i], q[i + 1][R]);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
143 ms |
4972 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
143 ms |
4972 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
163 ms |
4972 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
504 ms |
9324 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
530 ms |
9324 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
520 ms |
9436 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
526 ms |
9452 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
525 ms |
9324 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 |
9492 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
536 ms |
9364 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |