Submission #1233499

#TimeUsernameProblemLanguageResultExecution timeMemory
1233499antonnSoccer Stadium (IOI23_soccer)C++20
48 / 100
4648 ms1024312 KiB
#include "soccer.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 500 + 7; int a[N][N], pref[N][N], dp[2][N][N][N]; bool ok(int l, int x, int y) { return pref[l][y] - pref[l][x - 1] == 0; } int biggest_stadium(int n, vector<vector<int>> f) { for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { a[i][j] = f[i - 1][j - 1]; pref[i][j] = pref[i][j - 1] + a[i][j]; } } for (int down = 0; down < N; ++down) { for (int x = 0; x < N; ++x) { for (int y = x; y < N; ++y) { dp[0][down][x][y] = -1e9; dp[1][down][x][y] = -1e9; } } } for (int i = 1; i <= n; ++i) { for (int l = 1; l <= n; ++l) { for (int r = l; r <= n; ++r) { if (ok(i, l, r)) dp[1][i][l][r] = r - l + 1; } } } int ans = 0; for (int h2 = 1; h2 <= n; ++h2) { for (int down = 1; down + h2 - 1 <= n; ++down) { int up = down + h2 - 1; for (int l = n; l >= 1; --l) { for (int r = l; r <= n; ++r) { ans = max(ans, dp[h2 % 2][down][l][r]); // if (!ok(up, l, r)) break; for (int x = l; x <= r; ++x) { for (int y = x; y <= r; ++y) { if (ok(down - 1, x, y)) { dp[(h2 + 1) % 2][down - 1][x][y] = max(dp[(h2 + 1) % 2][down - 1][x][y], dp[h2 % 2][down][l][r] + y - x + 1); } else { break; } } for (int y = x; y <= r; ++y) { if (ok(up + 1, x, y)) { dp[(h2 + 1) % 2][down][x][y] = max(dp[(h2 + 1) % 2][down][x][y], dp[h2 % 2][down][l][r] + y - x + 1); } else { break; } } } dp[h2 % 2][down][l][r] = -1e9; } } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...