Submission #990081

#TimeUsernameProblemLanguageResultExecution timeMemory
990081haiphong5g0Boxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "boxes.h" #define task "CAU5" #define pl pair<ll, ll> #define pb push_back #define mp make_pair #define fi first #define se second #define FOR(i, a, b, c) for (ll i=a; i<=b; i+=c) #define FORE(i, a, b, c) for (ll i=a; i>=b; i+=c) using namespace std; using ll = long long; using ull = unsigned long long; const ll Mod = 998244353; const int maxn = 1e7+1; const ll Inf = 1e10; ll ans=0, n, k, l, A[maxn]; inline ll dis(ll a, ll l) { return min(a, l-a); } ll delivery(ll n, ll k, ll l, ll A[]) { ll a = -1, b = n, ans = 0; if (n % k != 0) { ans += min(dis(A[a+n%k],l), dis(A[b-n%k],l)) + dis(min(dis(A[a+n%k],l), dis(A[b-n%k],l)),l); if (dis(A[a+n%k],l) <= dis(A[b-n%k],l)) a += n%k; else b -= n%k; } while (a + 1 != b) { if (b - a == k + 1) { if (A[b-1] <= l/2) ans += (l/2)*2; else ans += l; break; } else { ans += min(dis(A[a+k],l), dis(A[b-k],l)) + dis(min(dis(A[a+k],l), dis(A[b-k],l)),l); if (dis(A[a+k],l) <= dis(A[b-k],l)) a+=k; else b-=k; } } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'll dis(ll, ll)':
boxes.cpp:18:24: warning: declaration of 'l' shadows a global declaration [-Wshadow]
   18 | inline ll dis(ll a, ll l)
      |                     ~~~^
boxes.cpp:17:17: note: shadowed declaration is here
   17 | ll ans=0, n, k, l, A[maxn];
      |                 ^
boxes.cpp: In function 'll delivery(ll, ll, ll, ll*)':
boxes.cpp:22:34: warning: declaration of 'A' shadows a global declaration [-Wshadow]
   22 | ll delivery(ll n, ll k, ll l, ll A[])
      |                               ~~~^~~
boxes.cpp:17:20: note: shadowed declaration is here
   17 | ll ans=0, n, k, l, A[maxn];
      |                    ^
boxes.cpp:22:28: warning: declaration of 'l' shadows a global declaration [-Wshadow]
   22 | ll delivery(ll n, ll k, ll l, ll A[])
      |                         ~~~^
boxes.cpp:17:17: note: shadowed declaration is here
   17 | ll ans=0, n, k, l, A[maxn];
      |                 ^
boxes.cpp:22:22: warning: declaration of 'k' shadows a global declaration [-Wshadow]
   22 | ll delivery(ll n, ll k, ll l, ll A[])
      |                   ~~~^
boxes.cpp:17:14: note: shadowed declaration is here
   17 | ll ans=0, n, k, l, A[maxn];
      |              ^
boxes.cpp:22:16: warning: declaration of 'n' shadows a global declaration [-Wshadow]
   22 | ll delivery(ll n, ll k, ll l, ll A[])
      |             ~~~^
boxes.cpp:17:11: note: shadowed declaration is here
   17 | ll ans=0, n, k, l, A[maxn];
      |           ^
boxes.cpp:24:23: warning: declaration of 'ans' shadows a global declaration [-Wshadow]
   24 |     ll a = -1, b = n, ans = 0;
      |                       ^~~
boxes.cpp:17:4: note: shadowed declaration is here
   17 | ll ans=0, n, k, l, A[maxn];
      |    ^~~
/usr/bin/ld: /tmp/cc7RHvRS.o: in function `main':
grader.c:(.text.startup+0x1ef): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status