Submission #932311

# Submission time Handle Problem Language Result Execution time Memory
932311 2024-02-23T07:56:40 Z teacup Shortcut (IOI16_shortcut) C++14
Compilation error
0 ms 0 KB
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ii pair<int,int>
#define vi vector<int>
typedef tuple<int,int,int> iii;
typedef tuple<int,int,int,int> iiii;
typedef vector<ii> vii; 

const int MAXN=255, ans=1e15; int curr;
vi AL[MAXN];
int pref[MAXN], suff[MAXN], sum[MAXN], S, E;
int find_shortcut(int32_t n, vi l, vi d, int32_t c){
    int temp=0;
    for (int i=1; i<=n; i++){
        pref[i] = max(pref[i-1],d[i-1]-temp);
        if (i<n) temp += l[i-1];
    }
    tot=0;
    for (int i=n; i>=1; i--){
        suff[i] = max(suff[i+1],d[i-1]-temp);
        if (i!=1) temp += l[i-2]; 
    }
    for (int i=0; i<n-1; i++){
        sum[i+2] = sum[i+1] + l[i];
    }
    
    for (int i=0; i<=n; i++){
        for (int j=i+1; j<=n; j++){
            curr=0;
            for (S=i; S<j; S++){
                for (E=S+1; E<=j; E++){
                    int ds = d[S-1], de=d[E-1];
                    if (S==i) ds = pref[s]+sum[s]-sum[1];
                    if (E==j) de = suff[e]+sum[n]-sum[e];
                    curr=max(curr,ds+de+min(sum[e]-sum[s],sum[j]-sum[i]-dis+c));
                }
            }
            for (S=i; S<=i; S++){
                for (E=S+1; E<=i; E++){
                    int ds = d[S-1], de=d[E-1];
                    curr=max(curr,ds+de+sum[E]-sum[S]);
                }
            }
            for (S=j; S<=i; S++){
                for (E=S+1; E<=i; E++){
                    int ds = d[S-1], de=d[E-1];
                    curr=max(curr,ds+de+sum[E]-sum[S]);
                }
            }
            ans = min(ans,curr);
        }
    }
    return ans;
}

Compilation message

shortcut.cpp: In function 'long long int find_shortcut(int32_t, std::vector<long long int>, std::vector<long long int>, int32_t)':
shortcut.cpp:21:5: error: 'tot' was not declared in this scope
   21 |     tot=0;
      |     ^~~
shortcut.cpp:36:41: error: 's' was not declared in this scope; did you mean 'ds'?
   36 |                     if (S==i) ds = pref[s]+sum[s]-sum[1];
      |                                         ^
      |                                         ds
shortcut.cpp:37:41: error: 'e' was not declared in this scope; did you mean 'de'?
   37 |                     if (E==j) de = suff[e]+sum[n]-sum[e];
      |                                         ^
      |                                         de
shortcut.cpp:38:49: error: 'e' was not declared in this scope; did you mean 'de'?
   38 |                     curr=max(curr,ds+de+min(sum[e]-sum[s],sum[j]-sum[i]-dis+c));
      |                                                 ^
      |                                                 de
shortcut.cpp:38:56: error: 's' was not declared in this scope; did you mean 'ds'?
   38 |                     curr=max(curr,ds+de+min(sum[e]-sum[s],sum[j]-sum[i]-dis+c));
      |                                                        ^
      |                                                        ds
shortcut.cpp:38:73: error: 'dis' was not declared in this scope; did you mean 'ds'?
   38 |                     curr=max(curr,ds+de+min(sum[e]-sum[s],sum[j]-sum[i]-dis+c));
      |                                                                         ^~~
      |                                                                         ds
shortcut.cpp:53:17: error: assignment of read-only variable 'ans'
   53 |             ans = min(ans,curr);
      |             ~~~~^~~~~~~~~~~~~~~