Submission #74145

# Submission time Handle Problem Language Result Execution time Memory
74145 2018-08-30T09:55:42 Z MKopchev Shortcut (IOI16_shortcut) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=1e6+42;
long long x[nmax];
long long find_shortcut(int n, int l[], int d[], int c)
{
    long long ans=1e18;
    x[0]=0;
    for(int i=1;i<n;i++)
        x[i]=x[i-1]+l[i-1];
    for(int p=0;p<n;p++)
        for(int q=p+1;q<n;q++)
        {
        long long now=0;
        //1<->1 type
        long long best=-1e18;
        for(int j=0;j<=p;j++)
        {
            now=max(now,d[j]+x[j]+best);
            best=max(best,d[j]-x[j]);
        }
        //3<->3 type
        best=-1e18;
        for(int j=q;j<n;j++)
        {
            now=max(now,d[j]+x[j]+best);
            best=max(best,d[j]-x[j]);
        }
        //1<->3 type
        best=-1e18;
        for(int i=0;i<=p;i++)
            best=max(best,d[i]-x[i]);
        for(int j=p;j<=q;j++)
            now=max(now,d[j]+x[j]+best);
        //1<->2 type
        best=-1e18;
        for(int i=0;i<=p;i++)
            best=max(best,d[i]-x[i]+x[p]);
        for(int j=p;j<=q;j++)
            now=max(now,best+d[j]+min(x[j]-x[p],x[q]-x[j]+c));
        //2<->3 type
        best=-1e18;
        for(int i=p;i<=q;i++)
            best=max(best,d[i]+min(x[i]-x[p]+c,x[q]-x[i]));
        for(int j=q;j<n;j++)
            now=max(now,best+d[j]+x[j]-x[q]);
        //2<->2 type
        for(int i=p;i<=q;i++)
            for(int j=i;j<=q;j++)
            now=max(now,d[i]+d[j]+min(x[j]-x[i],x[q]-x[j]+c+x[i]-x[p]));
        ans=min(ans,now);
        }
    return ans;
}
/*
const int n=4;
int l[n]={10,20,20};
int d[n]={0,40,0,30};
int c;
int main()
{
cout<<find_shortcut(n,l,d,c)<<endl;
return 0;
}
*/

Compilation message

/tmp/cckvDcCv.o: In function `main':
grader.cpp:(.text.startup+0x10d): undefined reference to `find_shortcut(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, int)'
collect2: error: ld returned 1 exit status