이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "soccer.h"
#define ar array
#define ll long long
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
const int nax = 31;
int dp[nax][nax][nax][nax];
int biggest_stadium(int n, std::vector<std::vector<int>> F)
{
memset(dp, 0xc0, sizeof(dp));
vector<vector<int>> to(n, vector<int>(n, -1));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) if (!F[i][j]) {
int r = j;
while (r+1 < n && !F[i][r+1]) r++;
for (int k = j; k <= r; k++) to[i][k] = r;
dp[i][i][j][r] = r-j+1;
j = r;
}
}
for (int len = 1; len < n; len++) {
for (int i = 0; i+len-1 < n; i++) {
int j = i+len-1;
for (int l = 0; l < n; l++) {
for (int r = l; r < n; r++) if (dp[i][j][l][r] > 0) {
if (i) {
for (int z = l; z <= r; z++) if (~to[i-1][z]) {
int new_r = min(to[i-1][z], r);
ckmax(dp[i-1][j][z][new_r], dp[i][j][l][r] + new_r - z + 1);
}
}
if (j+1 < n) {
for (int z = l; z <= r; z++) if (~to[j+1][z]) {
int new_r = min(to[j+1][z], r);
ckmax(dp[i][j+1][z][new_r], dp[i][j][l][r] + new_r - z + 1);
}
}
}
}
}
}
int ans = 0;
for (int i = 0; i < n; i++) for (int j = i; j < n; j++) for (int k = 0; k < n; k++) for (int l = k; l < n; l++) ckmax(ans, dp[i][j][k][l]);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |