QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#527849 | #7120. Soccer | green_gold_dog# | 0 | 2159ms | 4544kb | C++20 | 3.8kb | 2024-08-22 20:26:34 | 2024-08-22 20:26:37 |
Judging History
answer
#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll INF = 1'000'000'000;
template<typename T>
bool assign_max(T& a, T b) {
if (b > a) {
a = b;
return true;
}
return false;
}
ll biggest_stadium(ll n, vector<vector<ll>> f) {
vector<vector<ll>> tol(n, vector<ll>(n, 0)), tor(n, vector<ll>(n, 0));
for (ll i = 0; i < n; i++) {
for (ll j = 0; j < n; j++) {
if (f[i][j] == 0) {
tol[i][j] = 1;
if (j > 0) {
tol[i][j] += tol[i][j - 1];
}
}
}
for (ll j = n - 1; j >= 0; j--) {
if (f[i][j] == 0) {
tor[i][j] = 1;
if (j < n - 1) {
tor[i][j] += tor[i][j + 1];
}
}
}
}
ll ans = 0;
for (ll mid = 0; mid < n; mid++) {
for (ll ml = 0; ml < n; ml++) {
if (f[ml][mid] == 1) {
continue;
}
ll l = mid - tol[ml][mid] + 1, r = mid + tor[ml][mid] - 1;
vector<pair<ll, ll>> sup(1, make_pair(l, r)), sdown(1, make_pair(l, r));
for (ll j = ml - 1; j >= 0; j--) {
if (f[j][mid] == 1) {
continue;
}
if (mid - tol[j][mid] + 1 > l) {
l = mid - tol[j][mid] + 1;
}
if (mid + tor[j][mid] - 1 < r) {
r = mid + tor[j][mid] - 1;
}
sup.emplace_back(l, r);
}
l = mid - tol[ml][mid] + 1;
r = mid + tor[ml][mid] - 1;
for (ll j = ml + 1; j < n; j++) {
if (f[j][mid] == 1) {
continue;
}
if (mid - tol[j][mid] + 1 > l) {
l = mid - tol[j][mid] + 1;
}
if (mid + tor[j][mid] - 1 < r) {
r = mid + tor[j][mid] - 1;
}
sdown.emplace_back(l, r);
}
reverse(sup.begin(), sup.end());
reverse(sdown.begin(), sdown.end());
vector<vector<vector<vector<ll>>>> dp(sup.size() + 1, vector<vector<vector<ll>>>(sdown.size() + 1, vector<vector<ll>>(2, vector<ll>(2, -INF))));
dp[1][0][0][0] = sup[0].second - sup[0].first + 1;
dp[0][1][1][1] = sdown[0].second - sdown[0].first + 1;
for (ll i = 0; i <= sup.size(); i++) {
for (ll j = 0; j <= sdown.size(); j++) {
for (ll wl = 0; wl < 2; wl++) {
for (ll wr = 0; wr < 2; wr++) {
if (dp[i][j][wl][wr] == -INF) {
continue;
}
ll nl, nr;
if (wl) {
nl = sdown[j - 1].first;
} else {
nl = sup[i - 1].first;
}
if (wr) {
nr = sdown[j - 1].second;
} else {
nr = sup[i - 1].second;
}
if (i < sup.size()) {
auto[l, r] = sup[i];
if (l <= nl && nr <= r) {
assign_max(dp[i + 1][j][wl][wr], dp[i][j][wl][wr] + nr - nl + 1);
assign_max(dp[i + 1][j][1][wr], dp[i][j][wl][wr] + nr - l + 1);
assign_max(dp[i + 1][j][wl][1], dp[i][j][wl][wr] + r - nl + 1);
assign_max(dp[i + 1][j][1][1], dp[i][j][wl][wr] + r - l + 1);
}
}
if (j < sdown.size()) {
auto[l, r] = sdown[j];
if (l <= nl && nr <= r) {
assign_max(dp[i][j + 1][wl][wr], dp[i][j][wl][wr] + nr - nl + 1);
assign_max(dp[i][j + 1][0][wr], dp[i][j][wl][wr] + nr - l + 1);
assign_max(dp[i][j + 1][wl][0], dp[i][j][wl][wr] + r - nl + 1);
assign_max(dp[i][j + 1][0][0], dp[i][j][wl][wr] + r - l + 1);
}
}
}
}
}
}
l = mid - tol[ml][mid] + 1;
r = mid + tor[ml][mid] - 1;
ll nans = max({dp.back().back()[0][0], dp.back().back()[0][1], dp.back().back()[1][0], dp.back().back()[1][1]}) - (r - l + 1);
if (ans < nans) {
ans = nans;
}
}
}
return ans;
}
#ifdef LOCAL
int main()
{
int N;
assert(1 == scanf("%d", &N));
std::vector<std::vector<int>> F(N, std::vector<int>(N));
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
assert(1 == scanf("%d", &F[i][j]));
}
}
fclose(stdin);
int res = biggest_stadium(N, F);
printf("%d\n", res);
fclose(stdout);
return 0;
}
#endif
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 6
Accepted
time: 0ms
memory: 3840kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 1 0
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 1
result:
ok ok
Test #2:
score: 1.5
Acceptable Answer
time: 0ms
memory: 3836kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 0 0 1 0 0 0 0
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 6
result:
points 0.250 partial
Test #3:
score: 1.5
Acceptable Answer
time: 2159ms
memory: 4544kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 9900
result:
points 0.250 partial
Test #4:
score: 0
Time Limit Exceeded
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
result:
Subtask #2:
score: 0
Wrong Answer
Test #10:
score: 8
Accepted
time: 0ms
memory: 3840kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 0 0 1 0 0 1 1
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 5
result:
ok ok
Test #11:
score: 8
Accepted
time: 0ms
memory: 4124kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 0 0 1 1 0 0 1
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 5
result:
ok ok
Test #12:
score: 8
Accepted
time: 0ms
memory: 3800kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 1 0 0 0 1 1 0
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 5
result:
ok ok
Test #13:
score: 8
Accepted
time: 0ms
memory: 3856kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 1 0 0 1 0 1 0 0 1
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 4
result:
ok ok
Test #14:
score: 0
Wrong Answer
time: 0ms
memory: 4084kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 1 0 0 0 1 0 0
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 7
result:
wrong answer wrong
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%