# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
831092 |
2023-08-19T17:22:47 Z |
starchan |
Secret (JOI14_secret) |
C++17 |
|
387 ms |
8200 KB |
#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)1e3+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
int XXX;
int table[MX][MX];
void build(const int a[], int l, int r)
{
int m = (l+r)/2;
if(l == r)
{
table[m][m] = a[m];
return;
}
table[m][m] = a[m];
for(int i = m-1; i >= l; i--)
table[i][m] = Secret(a[i], table[i+1][m]);
table[m+1][m+1] = a[m+1];
for(int i = m+2; i <= r; i++)
table[m+1][i] = Secret(table[m+1][i-1], a[i]);
build(a, l, m);
build(a, m+1, r);
return;
}
int query(int ql, int qr, int l, int r)
{
if(ql == qr)
return table[ql][qr];
int m = (l+r)/2;
if(ql == (m+1))
return table[m+1][qr];
else if(qr == m)
return table[ql][m];
if(qr < m)
return query(ql, qr, l, m);
else if(ql >= (m+2))
return query(ql, qr, m+1, r);
else
return Secret(table[ql][m], table[m+1][qr]);
}
void Init(int n, int a[])
{
build(a, 0, n-1);
XXX = n;
return;
}
int Query(int l, int r)
{
return query(l, r, 0, XXX-1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
111 ms |
4300 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
111 ms |
4312 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
110 ms |
4336 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
382 ms |
8144 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
385 ms |
8180 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
378 ms |
8128 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
387 ms |
8184 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
384 ms |
8168 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
384 ms |
8200 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
385 ms |
8136 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |