이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "popa.h"
using namespace std;
int st[1001],dr[1001];
int maxst[1001],maxdr[1001];
int solutioneaza(int sta,int dre)
{
if(sta==dre)
return sta;
for(int i=sta;i<=dre;i++)
if(maxst[i]<=sta&&maxdr[i]>=dre)
{
if(i!=sta)
st[i]=solutioneaza(sta,i-1);
if(i!=dre)
dr[i]=solutioneaza(i+1,dre);
return i;
}
return -1;
}
int solve(int n,int *Left, int *Right)
{
for(int i=0;i<n;i++)
{
st[i]=dr[i]=-1;
maxst[i]=i-1;
maxdr[i]=i+1;
}
for(int i=0;i<n;i++)
{
while(maxst[i]!=-1&&query(maxst[i],i,i,i))
{
maxdr[maxst[i]]=max(maxdr[maxst[i]],i+1);
maxst[i]=maxst[maxst[i]];
}
if(maxst[i]!=-1)
maxdr[maxst[i]]=i+1;
}
for(int i=n-1;i>=0;i--)
{
while(maxdr[i]!=n&&query(i,maxdr[i],i,i))
maxdr[i]=maxdr[maxdr[i]];
}
for(int i=0;i<n;i++)
{
maxst[i]++;
maxdr[i]--;
}
int x=solutioneaza(0,n-1);
for(int i=0;i<n;i++)
{
Left[i]=st[i];
Right[i]=dr[i];
}
return x;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |