#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
int biggest_stadium(int n, vector<vector<int>> FF){
vector<vector<int>> F(n + 1, vector<int>(n + 1)), P(n + 1, vector<int>(n + 1));
for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++){
F[i][j] = FF[i - 1][j - 1];
P[i][j] = P[i][j - 1] + !F[i][j];
}
}
int M = 1e9, K = 0, C = 0;
for (int i = 1; i <= n; i++){
if (P[i][n]){
M = min(M, i);
K = max(K, i);
C++;
}
}
if (C != (K - M + 1)) return 0;
vector<pii> all;
int L = 0, R = 0, I = 0;
for (int i = M; i <= K; i++){
int mn = 1e9, mx = 0;
for (int j = 1; j <= n; j++){
if (!F[i][j]){
mn = min(mn, j);
mx = max(mx, j);
}
}
if (P[i][n] != (mx - mn + 1)) return 0;
all.pb({mn, mx});
if (i == M){
L = mn; R = mx;
}
else {
if (!I){
if (mn <= L && R <= mx){
L = mn; R = mx;
}
else {
if (L <= mn && mx <= R){
I = 1;
L = mn; R = mx;
}
else {
return 0;
}
}
}
else {
if (L <= mn && mx <= R){
L = mn; R = mx;
}
else {
return 0;
}
}
}
}
auto cmp = [&](pii x, pii y){
if (x.ff != y.ff) return x.ff < y.ff;
return x.ss > y.ss;
};
sort(all.begin(), all.end(), cmp);
for (int i = 0; i + 1 < all.size(); i++){
if (all[i].ss < all[i + 1].ss){
return 0;
}
}
int out = 0;
for (int i = 1; i <= n; i++) out += P[i][n];
return out;
}
# | 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... |