Submission #701012

# Submission time Handle Problem Language Result Execution time Memory
701012 2023-02-19T17:46:13 Z kien popa (BOI18_popa) C++14
100 / 100
109 ms 428 KB
#include <bits/stdc++.h>
#include "popa.h"
using namespace std;
int st[1001],dr[1001];
int maxst[1001];
int solutioneaza(int sta,int dre)
{
    if(sta==dre)
        return sta;
    for(int i=dre;i>=sta;i--)
        if(maxst[i]<=sta)
        {
            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]++;
    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 8 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 328 KB Output is correct
2 Correct 95 ms 300 KB Output is correct
3 Correct 45 ms 308 KB Output is correct
4 Correct 72 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 328 KB Output is correct
2 Correct 44 ms 356 KB Output is correct
3 Correct 74 ms 428 KB Output is correct
4 Correct 109 ms 328 KB Output is correct