# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1084803 | thangdz2k7 | Soccer Stadium (IOI23_soccer) | C++17 | 354 ms | 55888 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.
// author : thembululquaUwU
// 3.9.2024
#include <bits/stdc++.h>
#define left __left__
#define right __right__
#define pb push_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
const int MaxN = 2e5;
const int mod = 1e9 + 7;
void maxl(auto &a, auto b) {a = max(a, b);}
void minl(auto &a, auto b) {a = min(a, b);}
int biggest_stadium(int n, vector <vi> f){
vector <int> dp(n), h(n, -1);
vector <vi> cur(n); int res = 0;
for (int r = 0; r < n; ++ r){
for (int c = 0; c < n; ++ c){
if (f[r][c]){
h[c] = -1;
dp[c] = 0;
}
else cur[++ h[c]].pb(c);
}
vi left(n), right(n);
stack <int> stk;
for (int c = 0; c < n; ++ c){
while (stk.size() && h[c] <= h[stk.top()]) stk.pop();
left[c] = stk.empty() ? -1 : stk.top();
stk.push(c);
}
while (stk.size()) stk.pop();
for (int c = n - 1; c >= 0; -- c){
while (stk.size() && h[c] <= h[stk.top()]) stk.pop();
right[c] = stk.empty() ? n : stk.top();
stk.push(c);
}
for (int hh = 0; hh < n; ++ hh){
for (int c : cur[hh]){
int len = right[c] - left[c] - 1;
dp[c] += len;
if (left[c] > -1) maxl(dp[c], dp[left[c]] + len * (h[c] - h[left[c]]));
if (right[c] < n) maxl(dp[c], dp[right[c]] + len * (h[c] - h[right[c]]));
maxl(res, dp[c]);
}
cur[hh].clear();
}
}
return res;
}
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... |