#include<bits/stdc++.h>
using namespace std;
int n;
int Secret(int X, int Y);
struct SegmentTree{
vector<int>segTree;
void init(int n){
segTree.resize(4 * n);
}
void Build(int node, int l, int r, vector<int>&v){
if(l == r)segTree[node] = v[l];
else{
int mid = (l + r) >> 1;
Build(node * 2, l, mid, v);
Build(node * 2 + 1, mid + 1, r, v);
segTree[node] = Secret(segTree[node * 2], segTree[node * 2 + 1]);
}
}
int Query(int node, int l, int r, int ql, int qr){
if(ql <= l && r <= qr)return segTree[node];
if(ql > r || l > qr)return -1;
int mid = (l + r) >> 1;
int lc = Query(node * 2, l, mid, ql, qr);
int rc = Query(node * 2 + 1, mid + 1, r, ql, qr);
if(lc == -1)return rc;
if(rc == -1)return lc;
return Secret(lc, rc);
}
};
SegmentTree tree;
void Init(int N, int A[]) {
n = N;
vector<int>v(n + 1);
for(int i = 1;i <= n;++i){
v[i] = A[i - 1];
}
tree.init(n);
tree.Build(1, 1, n, v);
}
int Query(int L, int R) {
return tree.Query(1, 1, n, L + 1, R + 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
157 ms |
2380 KB |
Output is partially correct - number of calls to Secret by Init = 510, maximum number of calls to Secret by Query = 13 |
2 |
Partially correct |
165 ms |
2480 KB |
Output is partially correct - number of calls to Secret by Init = 511, maximum number of calls to Secret by Query = 14 |
3 |
Partially correct |
171 ms |
2368 KB |
Output is partially correct - number of calls to Secret by Init = 512, maximum number of calls to Secret by Query = 15 |
4 |
Partially correct |
484 ms |
4364 KB |
Output is partially correct - number of calls to Secret by Init = 998, maximum number of calls to Secret by Query = 15 |
5 |
Partially correct |
490 ms |
4376 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 15 |
6 |
Partially correct |
437 ms |
4308 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 4 |
7 |
Partially correct |
513 ms |
4488 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |
8 |
Partially correct |
513 ms |
4372 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |
9 |
Partially correct |
515 ms |
4304 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |
10 |
Partially correct |
503 ms |
4252 KB |
Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16 |