답안 #932309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932309 2024-02-23T07:54:29 Z teacup Shortcut (IOI16_shortcut) C++14
컴파일 오류
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; 

int MAXN=255, ans=1e15, curr;
vi adj[MAXN];
int pref[MAXN], suff[MAXN], sum[MAXN], start, end;
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 (start=i; start<j; start++){
                for (end=start+1; end<=j; end++){
                    int ds = d[start-1], de=d[end-1];
                    if (start==i) ds = pref[s]+sum[s]-sum[1];
                    if (end==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 (start=i; start<=i; start++){
                for (end=start+1; end<=i; end++){
                    int ds = d[start-1], de=d[end-1];
                    curr=max(curr,ds+de+sum[end]-sum[start]);
                }
            }
            for (start=j; start<=i; start++){
                for (end=start+1; end<=i; end++){
                    int ds = d[start-1], de=d[end-1];
                    curr=max(curr,ds+de+sum[end]-sum[start]);
                }
            }
            ans = min(ans,curr);
        }
    }
    return ans;
}

Compilation message

shortcut.cpp:13:12: error: array bound is not an integer constant before ']' token
   13 | vi adj[MAXN];
      |            ^
shortcut.cpp:14:14: error: array bound is not an integer constant before ']' token
   14 | int pref[MAXN], suff[MAXN], sum[MAXN], start, end;
      |              ^
shortcut.cpp:14:26: error: array bound is not an integer constant before ']' token
   14 | int pref[MAXN], suff[MAXN], sum[MAXN], start, end;
      |                          ^
shortcut.cpp:14:37: error: array bound is not an integer constant before ']' token
   14 | int pref[MAXN], suff[MAXN], sum[MAXN], start, end;
      |                                     ^
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:18:9: error: 'pref' was not declared in this scope
   18 |         pref[i] = max(pref[i-1],d[i-1]-temp);
      |         ^~~~
shortcut.cpp:21:5: error: 'tot' was not declared in this scope
   21 |     tot=0;
      |     ^~~
shortcut.cpp:23:9: error: 'suff' was not declared in this scope
   23 |         suff[i] = max(suff[i+1],d[i-1]-temp);
      |         ^~~~
shortcut.cpp:27:9: error: 'sum' was not declared in this scope
   27 |         sum[i+2] = sum[i+1] + l[i];
      |         ^~~
shortcut.cpp:34:22: error: reference to 'end' is ambiguous
   34 |                 for (end=start+1; end<=j; end++){
      |                      ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shortcut.cpp:2:
/usr/include/c++/10/valarray:1244:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
/usr/include/c++/10/valarray:1234:5: note:                 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
 1234 |     end(valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/vector:69,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/bits/range_access.h:100:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  100 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(const _Container&)'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(_Container&)'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/10/bits/stl_vector.h:63,
                 from /usr/include/c++/10/vector:67,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/initializer_list:101:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
  101 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
shortcut.cpp:14:47: note:                 'long long int end'
   14 | int pref[MAXN], suff[MAXN], sum[MAXN], start, end;
      |                                               ^~~
shortcut.cpp:34:35: error: reference to 'end' is ambiguous
   34 |                 for (end=start+1; end<=j; end++){
      |                                   ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shortcut.cpp:2:
/usr/include/c++/10/valarray:1244:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
/usr/include/c++/10/valarray:1234:5: note:                 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
 1234 |     end(valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/vector:69,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/bits/range_access.h:100:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  100 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(const _Container&)'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(_Container&)'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/10/bits/stl_vector.h:63,
                 from /usr/include/c++/10/vector:67,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/initializer_list:101:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
  101 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
shortcut.cpp:14:47: note:                 'long long int end'
   14 | int pref[MAXN], suff[MAXN], sum[MAXN], start, end;
      |                                               ^~~
shortcut.cpp:34:43: error: reference to 'end' is ambiguous
   34 |                 for (end=start+1; end<=j; end++){
      |                                           ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shortcut.cpp:2:
/usr/include/c++/10/valarray:1244:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
/usr/include/c++/10/valarray:1234:5: note:                 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
 1234 |     end(valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/vector:69,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/bits/range_access.h:100:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  100 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(const _Container&)'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(_Container&)'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/10/bits/stl_vector.h:63,
                 from /usr/include/c++/10/vector:67,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/initializer_list:101:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
  101 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
shortcut.cpp:14:47: note:                 'long long int end'
   14 | int pref[MAXN], suff[MAXN], sum[MAXN], start, end;
      |                                               ^~~
shortcut.cpp:35:47: error: reference to 'end' is ambiguous
   35 |                     int ds = d[start-1], de=d[end-1];
      |                                               ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shortcut.cpp:2:
/usr/include/c++/10/valarray:1244:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
/usr/include/c++/10/valarray:1234:5: note:                 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
 1234 |     end(valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/vector:69,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/bits/range_access.h:100:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  100 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(const _Container&)'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(_Container&)'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/10/bits/stl_vector.h:63,
                 from /usr/include/c++/10/vector:67,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/initializer_list:101:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
  101 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
shortcut.cpp:14:47: note:                 'long long int end'
   14 | int pref[MAXN], suff[MAXN], sum[MAXN], start, end;
      |                                               ^~~
shortcut.cpp:36:40: error: 'pref' was not declared in this scope
   36 |                     if (start==i) ds = pref[s]+sum[s]-sum[1];
      |                                        ^~~~
shortcut.cpp:36:45: error: 's' was not declared in this scope; did you mean 'ds'?
   36 |                     if (start==i) ds = pref[s]+sum[s]-sum[1];
      |                                             ^
      |                                             ds
shortcut.cpp:36:48: error: 'sum' was not declared in this scope
   36 |                     if (start==i) ds = pref[s]+sum[s]-sum[1];
      |                                                ^~~
shortcut.cpp:37:25: error: reference to 'end' is ambiguous
   37 |                     if (end==j) de = suff[e]+sum[n]-sum[e];
      |                         ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shortcut.cpp:2:
/usr/include/c++/10/valarray:1244:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
/usr/include/c++/10/valarray:1234:5: note:                 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
 1234 |     end(valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/vector:69,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/bits/range_access.h:100:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  100 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(const _Container&)'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(_Container&)'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/10/bits/stl_vector.h:63,
                 from /usr/include/c++/10/vector:67,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/initializer_list:101:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
  101 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
shortcut.cpp:14:47: note:                 'long long int end'
   14 | int pref[MAXN], suff[MAXN], sum[MAXN], start, end;
      |                                               ^~~
shortcut.cpp:37:38: error: 'suff' was not declared in this scope
   37 |                     if (end==j) de = suff[e]+sum[n]-sum[e];
      |                                      ^~~~
shortcut.cpp:37:43: error: 'e' was not declared in this scope; did you mean 'de'?
   37 |                     if (end==j) de = suff[e]+sum[n]-sum[e];
      |                                           ^
      |                                           de
shortcut.cpp:37:46: error: 'sum' was not declared in this scope
   37 |                     if (end==j) de = suff[e]+sum[n]-sum[e];
      |                                              ^~~
shortcut.cpp:38:45: error: 'sum' was not declared in this scope
   38 |                     curr=max(curr,ds+de+min(sum[e]-sum[s],sum[j]-sum[i]-dis+c));
      |                                             ^~~
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:42:22: error: reference to 'end' is ambiguous
   42 |                 for (end=start+1; end<=i; end++){
      |                      ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shortcut.cpp:2:
/usr/include/c++/10/valarray:1244:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
/usr/include/c++/10/valarray:1234:5: note:                 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
 1234 |     end(valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/vector:69,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/bits/range_access.h:100:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  100 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(const _Container&)'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(_Container&)'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/10/bits/stl_vector.h:63,
                 from /usr/include/c++/10/vector:67,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/initializer_list:101:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
  101 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
shortcut.cpp:14:47: note:                 'long long int end'
   14 | int pref[MAXN], suff[MAXN], sum[MAXN], start, end;
      |                                               ^~~
shortcut.cpp:42:35: error: reference to 'end' is ambiguous
   42 |                 for (end=start+1; end<=i; end++){
      |                                   ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from shortcut.cpp:2:
/usr/include/c++/10/valarray:1244:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
/usr/include/c++/10/valarray:1234:5: note:                 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
 1234 |     end(valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/vector:69,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/bits/range_access.h:100:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  100 |     end(_Tp (&__arr)[_Nm])
      |     ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(const _Container&)'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note:                 'template<class _Container> decltype (__cont.end()) std::end(_Container&)'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/10/bits/stl_vector.h:63,
                 from /usr/include/c++/10/vector:67,
                 from shortcut.h:2,
                 from shortcut.cpp:1:
/usr/include/c++/10/initializer_list:101:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
  101 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
shortcut.cpp:14:47: note:                 'long long int end'
   14 | int pref[MAXN], suff[MAXN], sum[MAXN], start, end;
      |                                               ^~~
shortcut.cpp:42:43: error: reference to 'end' is ambiguous
   42 |                 for (end=start+1; end<=i; end++){
      |                                           ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from /var/local/lib/isolate/708/box/pr