QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#294173 | #7120. Soccer | training4usaco | 0 | 250ms | 145336kb | C++17 | 2.5kb | 2023-12-30 09:04:15 | 2024-04-28 08:28:48 |
Judging History
answer
#include "soccer.h"
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
const int MAXN = 2e3 + 5;
const int INF = 1e9 + 7;
int ans = 0;
int grid[MAXN][MAXN];
int up[MAXN][MAXN], down[MAXN][MAXN];
int dp[MAXN][MAXN];
int prv[MAXN][MAXN], nxt[MAXN][MAXN];
int len[MAXN][MAXN];
void magic(int row, int u, int l, int r) {
dp[row][u] = down[row][u] * (r - l + 1);
len[row][u] = r - l + 1;
if(prv[row][u] != -1) {
magic(row, prv[row][u], l, u - 1);
dp[row][u] = max(dp[row][u], dp[row][prv[row][u]] + (r - u + 1) * down[row][u]);
}
if(nxt[row][u] != -1) {
magic(row, nxt[row][u], u + 1, r);
dp[row][u] = max(dp[row][u], dp[row][nxt[row][u]] + (u - l + 1) * down[row][u]);
}
if(dp[row - 1][u] != -INF) dp[row][u] = max(dp[row][u], dp[row - 1][u] + (len[row][u] - len[row - 1][u]) * down[row][u]);
ans = max(ans, dp[row][u]);
}
int biggest_stadium(int n, vector<vector<int>> f) {
for(int i = 0; i <= n + 1; ++i) for(int j = 0; j <= n + 1; ++j) grid[i][j] = 0;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= n; ++j) grid[i][j] = f[i - 1][j - 1];
}
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= n; ++j) {
if(grid[i][j]) up[i][j] = 0;
else up[i][j] = up[i - 1][j] + 1;
}
}
for(int i = n; i >= 1; --i) {
for(int j = 1; j <= n; ++j) {
if(grid[i][j]) down[i][j] = 0;
else down[i][j] = down[i + 1][j] + 1;
}
}
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= n; ++j) {
dp[i][j] = -INF;
prv[i][j] = nxt[i][j] = -1;
}
}
for(int i = 1; i <= n; ++i) {
int l = 1, r = 0;
for(int j = 1; j <= n; ++j)
while(l <= n) {
r = l;
if(grid[i][l] == 1) {
while(r <= n && grid[i][r]) ++r;
l = r + 1;
continue;
}
while(r < n && grid[i][r + 1] == 0) ++r;
stack<int> st;
for(int j = l; j <= r; ++j) {
while(st.size() && down[i][st.top()] > down[i][j]) {
prv[i][j] = st.top(); st.pop();
}
if(st.size()) nxt[i][st.top()] = j;
st.push(j);
}
while(st.size() > 1) st.pop();
magic(i, st.top(), l, r);
l = r + 1;
}
}
return ans;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 6
Accepted
time: 0ms
memory: 12012kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 1 0
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 1
result:
ok ok
Test #2:
score: 6
Accepted
time: 2ms
memory: 12036kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 0 0 1 0 0 0 0
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 5
result:
ok ok
Test #3:
score: 6
Accepted
time: 4ms
memory: 19444kb
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 9850
result:
ok ok
Test #4:
score: 6
Accepted
time: 12ms
memory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OK 79
result:
wrong answer wrong
Subtask #2:
score: 0
Wrong Answer
Test #10:
score: 8
Accepted
time: 0ms
memory: 12108kb
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: 12036kb
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: 14064kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 1 0 0 0 1 1 0
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 5
result:
ok ok
Test #13:
score: 2
Acceptable Answer
time: 2ms
memory: 14068kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 1 0 0 1 0 1 0 0 1
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 2
result:
points 0.250 partial
Test #14:
score: 8
Accepted
time: 0ms
memory: 14072kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 1 0 0 0 1 0 0
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 6
result:
ok ok
Test #15:
score: 8
Accepted
time: 2ms
memory: 12036kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 1 0 0 1 0 0 0
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 7
result:
ok ok
Test #16:
score: 8
Accepted
time: 2ms
memory: 11984kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 0 0 0 0 0 0 0
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 9
result:
ok ok
Test #17:
score: 8
Accepted
time: 2ms
memory: 12032kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 0 1 0 0 0 1 0
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 6
result:
ok ok
Test #18:
score: 8
Accepted
time: 2ms
memory: 12060kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 1 1 1 1 0 1 1
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 2
result:
ok ok
Test #19:
score: 8
Accepted
time: 2ms
memory: 12028kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 0 0 1 1 0 1 0 1 1
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 3
result:
ok ok
Test #20:
score: 0
Wrong Answer
time: 0ms
memory: 16168kb
input:
R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L 3 1 0 1 0 0 0 1 0 0
output:
xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0 OK 5
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%