#include <iostream>
#include <vector>
#include "secret.h"
using namespace std;
vector<int> v;
int segtree[10000];
void build(int l, int r, int node) {
if(l == r) {
segtree[node] = v[l];
return;
}
int mid = (l+r)/2;
build(l, mid, node*2);
build(mid+1, r, node*2+1);
segtree[node] = Secret(segtree[node*2], segtree[node*2+1]);
}
int que(int l, int r, int tl, int tr, int node) {
if(tl > r || tr < l) {
return -1;
}
if(l <= tl && tr <= r) {
return segtree[node];
}
int mid = (tl+tr)/2;
int a, b;
a = que(l, r, tl, mid, node*2);
b = que(l, r, mid+1, tr, node*2+1);
if(a == -1) {
return b;
}
if(b == -1) {
return a;
}
return Secret(a, b);
}
int lol;
int Query(int L, int R) {
L++;
R++;
return que(L, R, 1, lol, 1);
}
void Init(int N, int A[]) {
lol = N;
v.push_back(0);
for(int i=0; i<N; i++) {
v.push_back(A[i]);
}
build(1, N, 1);
}
int arr[100];
int main() {
int n, q;
cin >> n;
int a, b;
for(int i=0; i<n; i++) {
cin >> arr[i];
}
Init(n, arr);
cin >> q;
for(int i=0; i<q; i++) {
cin >> a >> b;
cout << Query(a, b) << "\n";
}
for(int i=0; i<=2*n; i++) {
cout << segtree[i] << " ";
}
return 0;
}
Compilation message
/usr/bin/ld: /tmp/cc3uSid2.o: in function `main':
secret.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccxYHVe3.o:grader-full.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status