This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "popa.h"
using namespace std;
int l[1009], r[1009];
int SOLVE(int le, int ri, int *Left, int *Right){
if(le > ri) return -1;
for(int i = le; i <= ri; i++){
if(l[i] <= le && r[i] >= ri){
int A = SOLVE(le, i - 1, Left, Right);
int B = SOLVE(i + 1, ri, Left, Right);
Left[i] = A;
Right[i] = B;
return i;
}
}
}
int solve(int N, int* Left, int* Right){
stack<int> S;
for(int i = 0; i < N; i++){
while(S.size() && query(S.top(), i,i,i)){
S.pop();
}
if(!S.size()) l[i] = 0;
else l[i] = S.top();
S.push(i);
}
while(S.size()) S.pop();
for(int i = N - 1; i >= 0; i--){
while(S.size() && query(i ,S.top(),i,i)){
S.pop();
}
if(!S.size()) r[i] = N - 1;
else r[i] = S.top();
S.push(i);
}
return SOLVE(0, N - 1, Left, Right);
}
Compilation message (stderr)
popa.cpp: In function 'int SOLVE(int, int, int*, int*)':
popa.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |