# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1056670 | Triseedot | Soccer Stadium (IOI23_soccer) | C++17 | 228 ms | 47644 KiB |
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;
}
}
}
vector pref_sum(N + 1, vector(N + 1, 0));
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
pref_sum[i + 1][j + 1] = pref_sum[i][j + 1] + pref_sum[i + 1][j] - pref_sum[i][j] + 1 - F[i][j];
}
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (!F[i][j]) {
debug(i, j);
if (pref_sum[col_first[j]][row_first[i]] > 0) {
return 0;
}
if (pref_sum[col_first[j]][N] - pref_sum[col_first[j]][row_last[i] + 1] > 0) {
debug(i, j);
return 0;
}
}
}
}
return cnt;
}
Compilation message (stderr)
# | 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... |