Submission #1096044

#TimeUsernameProblemLanguageResultExecution timeMemory
1096044HiepVu217Gondola (IOI14_gondola)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 17; int n, k, a[N][N], z; long long f[N][N], ans, s[N][N], ss[N][N]; long long calc (int l, int r) { return ss[r][r] - ss[r][l - 1]; } void dac (int l, int r, int from, int to) { if (l > r) { return; } int mid = l + r >> 1, x; for (int i = from; i <= min (mid, to); ++i) { long long s = f[z - 1][i] + calc (i + 1, mid); if (s < f[z][mid]) { f[z][mid] = s; x = i; } } dac (l, mid - 1, from, x); dac (mid + 1, r, x, to); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { cin >> a[i][j]; } } for (int i = 1; i <= n; ++i) { long long zz = 0; for (int j = 1; j <= i; ++j) { zz += a[i][j]; s[i][j] = zz; } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= i; ++j) { ss[i][j] = max (ss[i - 1][j - 1], ss[i - 1][j]) + s[i][j]; } } for (int i = 0; i <= k; ++i) { for (int j = 0; j <= n; ++j) { f[i][j] = 1e18; } } f[0][0] = 0; for (int i = 1; i <= k; ++i) { ++z; dac (i, n, i - 1, n - 1); } cout << f[k][n]; }

Compilation message (stderr)

gondola.cpp: In function 'void dac(int, int, int, int)':
gondola.cpp:16:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   16 |     int mid = l + r >> 1, x;
      |               ~~^~~
gondola.cpp:26:9: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |     dac (l, mid - 1, from, x);
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccUV9z1t.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc8Jxtvt.o:gondola.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccUV9z1t.o: in function `main':
grader.cpp:(.text.startup+0xb6): undefined reference to `valid'
/usr/bin/ld: grader.cpp:(.text.startup+0x108): undefined reference to `countReplacement'
/usr/bin/ld: grader.cpp:(.text.startup+0x132): undefined reference to `replacement'
collect2: error: ld returned 1 exit status