Submission #961178

#TimeUsernameProblemLanguageResultExecution timeMemory
961178ByeWorld비밀 (JOI14_secret)C++14
30 / 100
452 ms4504 KiB
#include "secret.h"
#include <bits/stdc++.h>
#include <random>
#define ll long long
// #define int long long
#define fi first
#define se second
#define pb push_back
#define md ((l+r)>>1)
#define lf (id<<1)
#define rg ((id<<1)|1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,pii> ipii;
const int MAXN = 1e3+10;
const int MAXA = 1e6+10;
const int INF = 2e9+10;
const int LOG = 30;
const int MOD = 1e9+7;

int n;
int a[MAXN];

struct seg {
	int st[4*MAXN];
	void bd(int id, int l, int r){
		if(l==r){
			st[id] = a[l]; return;
		}
		bd(lf, l, md); bd(rg, md+1, r);
		st[id] = Secret(st[lf], st[rg]);
	}
	int que(int id, int l, int r, int x, int y){
		if(x<=l && r<=y) return st[id];
		if(r<x || y<l) return -1;
		int le = que(lf, l, md, x, y), ri = que(rg, md+1, r, x, y);
		if(le==-1) return ri;
		else if(ri==-1) return le;
		else {
			return Secret(le, ri);
		}
	}
} A;

void Init(int N, int x[]) {
	n = N;
	for(int i=0; i<n; i++) a[i+1] = x[i];
	A.bd(1, 1, n);
}

int Query(int L, int R) {
	L++; R++;
	return A.que(1, 1, n, L, R);
}
#Verdict Execution timeMemoryGrader output
Fetching results...