#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 |
1 |
Partially correct |
1 ms |
336 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
336 KB |
ok |
2 |
Correct |
1 ms |
512 KB |
ok |
3 |
Correct |
1 ms |
336 KB |
ok |
4 |
Correct |
1 ms |
336 KB |
ok |
5 |
Correct |
1 ms |
336 KB |
ok |
6 |
Partially correct |
0 ms |
336 KB |
partial |
7 |
Partially correct |
2 ms |
336 KB |
partial |
8 |
Partially correct |
18 ms |
3216 KB |
partial |
9 |
Partially correct |
279 ms |
47432 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
336 KB |
ok |
2 |
Correct |
1 ms |
512 KB |
ok |
3 |
Incorrect |
1 ms |
336 KB |
wrong |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
336 KB |
partial |
2 |
Correct |
0 ms |
336 KB |
ok |
3 |
Correct |
1 ms |
512 KB |
ok |
4 |
Incorrect |
1 ms |
336 KB |
wrong |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
336 KB |
partial |
2 |
Correct |
0 ms |
336 KB |
ok |
3 |
Correct |
1 ms |
512 KB |
ok |
4 |
Correct |
1 ms |
336 KB |
ok |
5 |
Correct |
1 ms |
336 KB |
ok |
6 |
Incorrect |
1 ms |
336 KB |
wrong |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
336 KB |
partial |
2 |
Correct |
0 ms |
336 KB |
ok |
3 |
Correct |
1 ms |
512 KB |
ok |
4 |
Correct |
1 ms |
336 KB |
ok |
5 |
Correct |
1 ms |
336 KB |
ok |
6 |
Incorrect |
1 ms |
336 KB |
wrong |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
336 KB |
partial |
2 |
Correct |
0 ms |
336 KB |
ok |
3 |
Correct |
1 ms |
512 KB |
ok |
4 |
Correct |
1 ms |
336 KB |
ok |
5 |
Correct |
1 ms |
336 KB |
ok |
6 |
Correct |
1 ms |
336 KB |
ok |
7 |
Partially correct |
0 ms |
336 KB |
partial |
8 |
Partially correct |
2 ms |
336 KB |
partial |
9 |
Partially correct |
18 ms |
3216 KB |
partial |
10 |
Partially correct |
279 ms |
47432 KB |
partial |
11 |
Incorrect |
1 ms |
336 KB |
wrong |
12 |
Halted |
0 ms |
0 KB |
- |