Submission #363603

#TimeUsernameProblemLanguageResultExecution timeMemory
363603Sparky_09Boxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define trav(a, x) for(auto& a : x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<ll, ll> pii; typedef vector<ll> vi; typedef vector<pii> vpi; void usaco(string s){ freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } ll maxn = 1e7+1000, n1, k1, l1; ll pre[maxn+2], suf[maxn+2], pos1[maxn+2]; int delivery(int n, int k, int l, int pos[]){ n1=n;k1=k;l1=l; for(int i = 0; i < n; i++) pos1[i] = pos[i]; for(int i = 0; i < n; i++){ pre[i] = (i>=k?pre[i-k]+min(l1,2*pos1[i]):min(l1,2*pos1[i])); } for(int i = n-1; i >= 0; i--){ suf[i] = (i<=n-1-k?suf[i+k]+min(l1,2*(l1-pos1[i])):min(l1,2*(l1-pos1[i]))); } ll ans = min(pre[0],suf[0]); for(int i = 0; i < n; i++){ ans = min(ans, pre[i] + suf[i+1]); } return ans; }

Compilation message (stderr)

boxes.cpp:18:14: error: array bound is not an integer constant before ']' token
   18 | ll pre[maxn+2], suf[maxn+2], pos1[maxn+2];
      |              ^
boxes.cpp:18:27: error: array bound is not an integer constant before ']' token
   18 | ll pre[maxn+2], suf[maxn+2], pos1[maxn+2];
      |                           ^
boxes.cpp:18:41: error: array bound is not an integer constant before ']' token
   18 | ll pre[maxn+2], suf[maxn+2], pos1[maxn+2];
      |                                         ^
boxes.cpp: In function 'int delivery(int, int, int, int*)':
boxes.cpp:22:29: error: 'pos1' was not declared in this scope; did you mean 'pos'?
   22 |  for(int i = 0; i < n; i++) pos1[i] = pos[i];
      |                             ^~~~
      |                             pos
boxes.cpp:24:4: error: 'pre' was not declared in this scope
   24 |    pre[i] = (i>=k?pre[i-k]+min(l1,2*pos1[i]):min(l1,2*pos1[i]));
      |    ^~~
boxes.cpp:24:37: error: 'pos1' was not declared in this scope; did you mean 'pos'?
   24 |    pre[i] = (i>=k?pre[i-k]+min(l1,2*pos1[i]):min(l1,2*pos1[i]));
      |                                     ^~~~
      |                                     pos
boxes.cpp:27:4: error: 'suf' was not declared in this scope
   27 |    suf[i] = (i<=n-1-k?suf[i+k]+min(l1,2*(l1-pos1[i])):min(l1,2*(l1-pos1[i])));
      |    ^~~
boxes.cpp:27:45: error: 'pos1' was not declared in this scope; did you mean 'pos'?
   27 |    suf[i] = (i<=n-1-k?suf[i+k]+min(l1,2*(l1-pos1[i])):min(l1,2*(l1-pos1[i])));
      |                                             ^~~~
      |                                             pos
boxes.cpp:29:15: error: 'pre' was not declared in this scope
   29 |  ll ans = min(pre[0],suf[0]);
      |               ^~~
boxes.cpp:29:22: error: 'suf' was not declared in this scope
   29 |  ll ans = min(pre[0],suf[0]);
      |                      ^~~
boxes.cpp:33:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   33 |  return ans;
      |         ^~~
boxes.cpp: In function 'void usaco(std::string)':
boxes.cpp:13:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |   freopen((s+".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boxes.cpp:14:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |   freopen((s+".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~