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 <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#else
#define debug(...) 42
#endif
using ll = long long;
#define all(v) v.begin(), v.end()
#define len(v) int(v.size())
const ll INF = 1e18;
int biggest_stadium(int N, vector<vector<int>> F) {
vector<int> row_first(N, -1), row_last(N, -1), col_first(N, -1), col_last(N, -1);
int cnt = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (!F[i][j]) {
cnt++;
if (row_last[i] != -1 && row_last[i] != j - 1) {
return 0;
}
row_last[i] = j;
if (row_first[i] == -1) row_first[i] = j;
}
}
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (!F[j][i]) {
if (col_last[i] != -1 && col_last[i] != j - 1) {
return 0;
}
col_last[i] = j;
if (col_first[i] == -1) col_first[i] = j;
}
}
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (!F[i][j]) {
if (row_first[i] != 0) {
if (col_first[j] != 0) {
if (!F[col_first[j] - 1][row_first[i] - 1]) {
return 0;
}
}
if (col_last[j] != N - 1) {
if (!F[col_last[j] + 1][row_first[i] - 1]) {
return 0;
}
}
}
if (row_last[i] != N - 1) {
if (col_first[j] != 0) {
if (!F[col_first[j] - 1][row_last[i] + 1]) {
return 0;
}
}
if (col_last[j] != N - 1) {
if (!F[col_last[j] + 1][row_last[i] + 1]) {
return 0;
}
}
}
}
}
}
return cnt;
}
# | 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... |