# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
645755 |
2022-09-27T20:05:34 Z |
Kripton |
popa (BOI18_popa) |
C++14 |
|
117 ms |
420 KB |
#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;
}
for(int i=0;i<n;i++)
while(maxst[i]!=-1&&query(maxst[i],i,i,i))
maxst[i]=maxst[maxst[i]];
for(int i=0;i<n;i++)
maxst[i]++;
for(int i=n-1;i>=0;i--)
{
maxdr[i]=i;
int j;
for(j=i+1;j<n;j++)
if(maxst[j]<maxst[i])
{
maxdr[i]=j-1;
break;
}
else if(maxst[j]==maxst[i])
{
if(query(maxst[i],i,maxst[j],j))
maxdr[i]=maxdr[j];
else
maxdr[i]=j-1;
break;
}
if(j==n)
maxdr[i]=n-1;
}
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 |
1 |
Correct |
9 ms |
208 KB |
Output is correct |
2 |
Correct |
10 ms |
208 KB |
Output is correct |
3 |
Correct |
5 ms |
208 KB |
Output is correct |
4 |
Correct |
9 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
116 ms |
304 KB |
Output is correct |
2 |
Correct |
103 ms |
420 KB |
Output is correct |
3 |
Correct |
84 ms |
300 KB |
Output is correct |
4 |
Correct |
117 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
208 KB |
too many queries |
2 |
Halted |
0 ms |
0 KB |
- |