# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1072302 | Zicrus | Soccer Stadium (IOI23_soccer) | C++17 | 4595 ms | 596 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>
#include "soccer.h"
using namespace std;
typedef long long ll;
int n;
vector<vector<int>> f;
vector<vector<int>> sum;
int search(vector<pair<int, int>> prev, int res, int mn, int mx, bool dec) {
if (sum[prev.size()][mx+1] - sum[prev.size()][mn] > 0) return res;
for (auto &e : prev) {
if (e.first == -1) continue;
if (mn < e.first && mx < e.second) return res;
if (mn > e.first && mx > e.second) return res;
}
prev.push_back({mn, mx});
res += mx - mn + 1;
int best = res;
if (prev.size() == n)
return best;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
if (dec && (i < mn || j > mx)) continue;
bool d = dec || i > mn || j < mx;
best = max(best, search(prev, res, i, j, d));
}
}
return best;
}
int biggest_stadium(int N, vector<vector<int>> F) {
n = N; f = F;
sum = vector<vector<int>>(n, vector<int>(n+1));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
sum[i][j+1] = sum[i][j] + f[i][j];
}
}
vector<pair<int, int>> prev;
int start = 0;
while (sum[start].back() == n) {
start++;
prev.push_back({-1, -1});
}
int best = 0;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
best = max(best, search(prev, 0, i, j, false));
}
}
return best;
}
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... |