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"
#define MAXN 1007
using namespace std;
int ls[MAXN],rs[MAXN],dml[MAXN],dmr[MAXN];
int rek(int lt,int rt)
{
if(lt>rt) return -1;
int l=lt;
while(l<=rt && (dml[l]>lt || dmr[l]<rt)) l++;
ls[l]=rek(lt,l-1);
rs[l]=rek(l+1,rt);
return l;
}
int solve(int N,int* Left,int* Right)
{
stack<int> st;
for(int i=0;i<N;i++)
{
while(!st.empty()) {if(!query(st.top(),st.top(),st.top(),i)) {dmr[st.top()]=i-1; st.pop();} else break;}
if(!st.empty()) dml[i]=st.top()+1;
else dml[i]=0;
st.push(i);
}
while(!st.empty()) {dmr[st.top()]=N-1; st.pop();}
int a=rek(0,N-1);
for(int i=0;i<N;i++) Left[i]=ls[i];
for(int i=0;i<N;i++) Right[i]=rs[i];
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |