Submission #138256

# Submission time Handle Problem Language Result Execution time Memory
138256 2019-07-29T16:21:26 Z neki Boxes with souvenirs (IOI15_boxes) C++14
Compilation error
0 ms 0 KB
#include "boxes.h"
#include <bits/stdc++.h>
#define maxn 1010000
#define loop(i, a, b) for(int i=a;i<b;i++)
using namespace std;
typedef long long ll;
ll dsp[maxn], dod[maxn], a[maxn];

ll min (ll a, ll b){return (a<b) ? a:b;}
ll max (ll a, ll b){return (a>b) ? a:b;}

long long delivery(int N, int K, int L, int p[]) {
    loop(i, 0, N) a[i+1]=p[i];
    dod[0]=0;dsp[N+1]=0
    loop(i, 1, N+1) dod[i]=dod[max(0, i-k)]+2* a[i];
    for(int i=N;i>0;i--) dsp[i]=dsp[min(N+1, i+k)]+2*(L-a[i]);
    ll ans;
    loop(i, 0, N+1) ans=min(ans, dod[i]+dsp[i+1]);
    loop(i, 0, N-K+1) ans=min(ans, dod[i]+dsp[i+k+1]+L);
}

Compilation message

boxes.cpp: In function 'll min(ll, ll)':
boxes.cpp:9:19: warning: declaration of 'a' shadows a global declaration [-Wshadow]
 ll min (ll a, ll b){return (a<b) ? a:b;}
                   ^
boxes.cpp:7:26: note: shadowed declaration is here
 ll dsp[maxn], dod[maxn], a[maxn];
                          ^
boxes.cpp: In function 'll max(ll, ll)':
boxes.cpp:10:19: warning: declaration of 'a' shadows a global declaration [-Wshadow]
 ll max (ll a, ll b){return (a>b) ? a:b;}
                   ^
boxes.cpp:7:26: note: shadowed declaration is here
 ll dsp[maxn], dod[maxn], a[maxn];
                          ^
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:4:23: error: expected ';' before 'for'
 #define loop(i, a, b) for(int i=a;i<b;i++)
                       ^
boxes.cpp:15:5: note: in expansion of macro 'loop'
     loop(i, 1, N+1) dod[i]=dod[max(0, i-k)]+2* a[i];
     ^~~~
boxes.cpp:15:10: error: 'i' was not declared in this scope
     loop(i, 1, N+1) dod[i]=dod[max(0, i-k)]+2* a[i];
          ^
boxes.cpp:4:35: note: in definition of macro 'loop'
 #define loop(i, a, b) for(int i=a;i<b;i++)
                                   ^
boxes.cpp:16:13: warning: declaration of 'i' shadows a previous local [-Wshadow]
     for(int i=N;i>0;i--) dsp[i]=dsp[min(N+1, i+k)]+2*(L-a[i]);
             ^
boxes.cpp:15:10: note: shadowed declaration is here
     loop(i, 1, N+1) dod[i]=dod[max(0, i-k)]+2* a[i];
          ^
boxes.cpp:4:35: note: in definition of macro 'loop'
 #define loop(i, a, b) for(int i=a;i<b;i++)
                                   ^
boxes.cpp:16:48: error: 'k' was not declared in this scope
     for(int i=N;i>0;i--) dsp[i]=dsp[min(N+1, i+k)]+2*(L-a[i]);
                                                ^
boxes.cpp:18:10: warning: declaration of 'i' shadows a previous local [-Wshadow]
     loop(i, 0, N+1) ans=min(ans, dod[i]+dsp[i+1]);
          ^
boxes.cpp:4:31: note: in definition of macro 'loop'
 #define loop(i, a, b) for(int i=a;i<b;i++)
                               ^
boxes.cpp:15:10: note: shadowed declaration is here
     loop(i, 1, N+1) dod[i]=dod[max(0, i-k)]+2* a[i];
          ^
boxes.cpp:4:35: note: in definition of macro 'loop'
 #define loop(i, a, b) for(int i=a;i<b;i++)
                                   ^
boxes.cpp:19:10: warning: declaration of 'i' shadows a previous local [-Wshadow]
     loop(i, 0, N-K+1) ans=min(ans, dod[i]+dsp[i+k+1]+L);
          ^
boxes.cpp:4:31: note: in definition of macro 'loop'
 #define loop(i, a, b) for(int i=a;i<b;i++)
                               ^
boxes.cpp:15:10: note: shadowed declaration is here
     loop(i, 1, N+1) dod[i]=dod[max(0, i-k)]+2* a[i];
          ^
boxes.cpp:4:35: note: in definition of macro 'loop'
 #define loop(i, a, b) for(int i=a;i<b;i++)
                                   ^
boxes.cpp:19:49: error: 'k' was not declared in this scope
     loop(i, 0, N-K+1) ans=min(ans, dod[i]+dsp[i+k+1]+L);
                                                 ^
boxes.cpp:20:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^