Submission #645741

# Submission time Handle Problem Language Result Execution time Memory
645741 2022-09-27T19:01:38 Z Kripton popa (BOI18_popa) C++14
61 / 100
848 ms 352 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;
    for(int i=0;i<n;i++)
    {
        int r=i,pas=1<<9;
        while(pas)
        {
            if(r+pas<n&&query(i,r+pas,i,i))
                r+=pas;
            pas/=2;
        }
        maxdr[i]=r;
        r=i;
        pas=1<<9;
        while(pas)
        {
            if(r-pas>=0&&query(r-pas,i,i,i))
                r-=pas;
            pas/=2;
        }
        maxst[i]=r;
    }
    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 47 ms 312 KB Output is correct
2 Correct 55 ms 208 KB Output is correct
3 Correct 59 ms 208 KB Output is correct
4 Correct 53 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 682 ms 328 KB Output is correct
2 Correct 826 ms 328 KB Output is correct
3 Correct 425 ms 352 KB Output is correct
4 Correct 848 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 208 KB too many queries
2 Halted 0 ms 0 KB -