#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]=-1;
maxdr[i]=n;
}
for(int i=0;i<n;i++)
{
maxst[i]=i-1;
while(maxst[i]!=-1&&query(maxst[i],i,i,i))
maxst[i]=maxst[maxst[i]];
if(maxst[i]!=-1)
maxdr[maxst[i]]=i+1;
}
for(int i=n-1;i>=0;i--)
{
if(maxdr[i]==n)
maxdr[i]=i+1;
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
208 KB |
Output is correct |
2 |
Correct |
13 ms |
208 KB |
Output is correct |
3 |
Correct |
11 ms |
208 KB |
Output is correct |
4 |
Correct |
13 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
152 ms |
300 KB |
Output is correct |
2 |
Correct |
124 ms |
332 KB |
Output is correct |
3 |
Correct |
59 ms |
328 KB |
Output is correct |
4 |
Correct |
134 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
208 KB |
too many queries |
2 |
Halted |
0 ms |
0 KB |
- |