제출 #1233505

#제출 시각아이디문제언어결과실행 시간메모리
1233505antonn축구 경기장 (IOI23_soccer)C++20
48 / 100
4655 ms1522640 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], sum[N][N][N]; bool ok(int l, int x, int y) { return pref[l][y] - pref[l][x - 1] == 0; } bool ok(int l, int r, int x, int y) { return sum[x][y][r] - sum[x][y][l - 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 l = 1; l <= n; ++l) { for (int r = 1; r <= n; ++r) { for (int i = 1; i <= n; ++i) { sum[l][r][i] = sum[l][r][i - 1] + pref[i][r] - pref[i][l - 1]; } } } 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(down, up, l, r)) break; for (int x = l; x <= r; ++x) { for (int y = x; y <= r; ++y) { if (ok(down - 1, up, 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(down, 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...