This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "soccer.h"
using namespace std;
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
bool f = true;
int c = 0;
vector<vector<int>> d(N, vector<int>(N));
if (1 == F[0][0]) {
d[0][0] = 2;
}
if (1 == F[0][N - 1]) {
d[0][N - 1] = 2;
}
if (1 == F[N - 1][0]) {
d[N - 1][0] = 2;
}
if (1 == F[N - 1][N - 1]) {
d[N - 1][N - 1] = 2;
}
for (int i = 0; i < N; i ++) {
for (int j = 0; j < N; j ++) {
if (0 < i) {
d[i][j] = max(d[i][j], d[i - 1][j]);
}
if (0 < j) {
d[i][j] = max(d[i][j - 1], d[i][j]);
}
if (i < N - 1) {
d[i][j] = max(d[i + 1][j], d[i][j]);
}
if (j < N - 1) {
d[i][j] = max(d[i][j + 1], d[i][j]);
}
}
for (int j = N - 1; 0 <= j; j --) {
if (0 < i) {
d[i][j] = max(d[i][j], d[i - 1][j]);
}
if (0 < j) {
d[i][j] = max(d[i][j - 1], d[i][j]);
}
if (i < N - 1) {
d[i][j] = max(d[i + 1][j], d[i][j]);
}
if (j < N - 1) {
d[i][j] = max(d[i][j + 1], d[i][j]);
}
}
}
for (int i = N - 1; 0 <= i; i --) {
for (int j = 0; j < N; j ++) {
if (0 < i) {
d[i][j] = max(d[i][j], d[i - 1][j]);
}
if (0 < j) {
d[i][j] = max(d[i][j - 1], d[i][j]);
}
if (i < N - 1) {
d[i][j] = max(d[i + 1][j], d[i][j]);
}
if (j < N - 1) {
d[i][j] = max(d[i][j + 1], d[i][j]);
}
}
for (int j = N - 1; 0 <= j; j --) {
if (0 < i) {
d[i][j] = max(d[i][j], d[i - 1][j]);
}
if (0 < j) {
d[i][j] = max(d[i][j - 1], d[i][j]);
}
if (i < N - 1) {
d[i][j] = max(d[i + 1][j], d[i][j]);
}
if (j < N - 1) {
d[i][j] = max(d[i][j + 1], d[i][j]);
}
}
}
for (int i = 0; i < N; i ++) {
for (int j = 0; j < N; j ++) {
if (F[i][j] == 1) {
if (0 == d[i][j]) {
f = false;
}
} else {
c ++;
}
}
}
if (f) {
return c;
}
return 0;
}
# | 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... |