# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
823804 | Alihan_8 | 비밀 (JOI14_secret) | C++17 | 367 ms | 4372 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
#define ln '\n'
//#define int long long
template <class _T>
bool chmin(_T &x, const _T &y){
bool flag = false;
if ( x > y ){
x = y; flag |= true;
}
return flag;
}
template <class _T>
bool chmax(_T &x, const _T &y){
bool flag = false;
if ( x < y ){
x = y; flag |= true;
}
return flag;
}
const int N = 1e3 + 1;
struct SegTree{
int T[N * 4], n;
void build(vector <int> &a){
n = (int)a.size();
auto F = [&](auto &F, int v, int l, int r) -> void{
if ( l == r ){
T[v] = a[l];
return;
}
int md = (l + r) >> 1;
F(F, v * 2, l, md), F(F, v * 2 + 1, md + 1, r);
T[v] = Secret(T[v * 2], T[v * 2 + 1]);
};
F(F, 1, 0, n - 1);
}
int get(int v, int l, int r, int tl, int tr){
if ( l > tr or r < tl ){
return -1;
}
if ( l <= tl and r >= tr ){
return T[v];
}
int md = (l + r) >> 1;
int L = get(v * 2, l, md, tl, tr), R = get(v * 2 + 1, md + 1, r, tl, tr);
return Secret(L, R);
}
int get(int L, int R){
return get(1, 0, n - 1, L, R);
}
} tuf;
void Init(int n, int A[]) {
vector <int> a;
for ( int i = 0; i < n; i++ ){
a.pb(A[i]);
}
tuf.build(a);
}
int Query(int L, int R) {
return tuf.get(L, R);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |