#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define SIZE(x) (int)x.size()
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define dforsn(i,s,n) for(int i=int(n)-1;i>=int(s);i--)
#define dforn(i,n) for(int i=int(n)-1;i>=0;i--)
#define fst first
#define snd second
typedef pair<int,int> ii;
const int MAXN = 500;
int f[MAXN][MAXN];
int dp[MAXN][MAXN];
ii ran[MAXN][MAXN];
int L[MAXN][MAXN], R[MAXN][MAXN];
int n;
pair<int,ii> solve(int l, int r, int p) {
if(l>r) return {0LL,{-1,n}};
if(dp[l][r]!=-1) return {dp[l][r],ran[l][r]};
auto calculate = [&](pair<int,ii> prev, int i) {
auto [val,range] = prev;
int mini = max(range.fst, L[i][p]), maxi = min(range.snd, R[i][p]);
return (pair<int,ii>){val+max(maxi-mini-1,0),{mini,maxi}};
};
pair<int,ii> res = max(calculate(solve(l+1,r,p),l),
calculate(solve(l,r-1,p),r));
dp[l][r]=res.fst, ran[l][r]=res.snd;
return res;
}
int biggest_stadium(int N, vector<vector<int>> F) {
n=N;
forn(i,n) forn(j,n) {
f[i][j]=F[i][j];
}
forn(i,n) {
int k=-1;
forn(j,n) {
if(f[i][j]==1) k=j;
L[i][j]=k;
}
}
forn(i,n) {
int k=n;
dforn(j,n) {
if(f[i][j]==1) k=j;
R[i][j]=k;
}
}
int ans=0;
forn(i,n) {
memset(dp, -1, sizeof dp);
ans=max(ans,solve(0,n-1,i).fst);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4952 KB |
ok |
2 |
Correct |
1 ms |
4956 KB |
ok |
3 |
Correct |
1 ms |
4956 KB |
ok |
4 |
Correct |
1 ms |
4956 KB |
ok |
5 |
Correct |
1 ms |
4956 KB |
ok |
6 |
Correct |
1 ms |
5076 KB |
ok |
7 |
Correct |
14 ms |
5468 KB |
ok |
8 |
Correct |
1482 ms |
8348 KB |
ok |
9 |
Runtime error |
280 ms |
74144 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4952 KB |
ok |
2 |
Correct |
1 ms |
4956 KB |
ok |
3 |
Correct |
1 ms |
4956 KB |
ok |
4 |
Correct |
1 ms |
4956 KB |
ok |
5 |
Correct |
1 ms |
4952 KB |
ok |
6 |
Correct |
1 ms |
4956 KB |
ok |
7 |
Correct |
1 ms |
4956 KB |
ok |
8 |
Correct |
1 ms |
4956 KB |
ok |
9 |
Correct |
2 ms |
4956 KB |
ok |
10 |
Correct |
1 ms |
4956 KB |
ok |
11 |
Correct |
1 ms |
4956 KB |
ok |
12 |
Correct |
2 ms |
4956 KB |
ok |
13 |
Correct |
1 ms |
4952 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
ok |
2 |
Correct |
2 ms |
4952 KB |
ok |
3 |
Correct |
1 ms |
4956 KB |
ok |
4 |
Correct |
1 ms |
4956 KB |
ok |
5 |
Correct |
1 ms |
4956 KB |
ok |
6 |
Correct |
1 ms |
4952 KB |
ok |
7 |
Correct |
1 ms |
4956 KB |
ok |
8 |
Correct |
1 ms |
4956 KB |
ok |
9 |
Correct |
1 ms |
4956 KB |
ok |
10 |
Correct |
2 ms |
4956 KB |
ok |
11 |
Correct |
1 ms |
4956 KB |
ok |
12 |
Correct |
1 ms |
4956 KB |
ok |
13 |
Correct |
2 ms |
4956 KB |
ok |
14 |
Correct |
1 ms |
4952 KB |
ok |
15 |
Correct |
1 ms |
4952 KB |
ok |
16 |
Correct |
1 ms |
4952 KB |
ok |
17 |
Correct |
1 ms |
4956 KB |
ok |
18 |
Correct |
2 ms |
4956 KB |
ok |
19 |
Correct |
1 ms |
4956 KB |
ok |
20 |
Correct |
1 ms |
4956 KB |
ok |
21 |
Correct |
1 ms |
4956 KB |
ok |
22 |
Correct |
2 ms |
5120 KB |
ok |
23 |
Correct |
2 ms |
4956 KB |
ok |
24 |
Correct |
1 ms |
4956 KB |
ok |
25 |
Correct |
1 ms |
5208 KB |
ok |
26 |
Correct |
1 ms |
5060 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
ok |
2 |
Correct |
2 ms |
4952 KB |
ok |
3 |
Correct |
1 ms |
4956 KB |
ok |
4 |
Correct |
1 ms |
4956 KB |
ok |
5 |
Correct |
1 ms |
4956 KB |
ok |
6 |
Correct |
1 ms |
4956 KB |
ok |
7 |
Correct |
1 ms |
4956 KB |
ok |
8 |
Correct |
1 ms |
4952 KB |
ok |
9 |
Correct |
1 ms |
4956 KB |
ok |
10 |
Correct |
1 ms |
4956 KB |
ok |
11 |
Correct |
1 ms |
4956 KB |
ok |
12 |
Correct |
2 ms |
4956 KB |
ok |
13 |
Correct |
1 ms |
4956 KB |
ok |
14 |
Correct |
1 ms |
4956 KB |
ok |
15 |
Correct |
2 ms |
4956 KB |
ok |
16 |
Correct |
1 ms |
4952 KB |
ok |
17 |
Correct |
1 ms |
4952 KB |
ok |
18 |
Correct |
1 ms |
4952 KB |
ok |
19 |
Correct |
1 ms |
4956 KB |
ok |
20 |
Correct |
2 ms |
4956 KB |
ok |
21 |
Correct |
1 ms |
4956 KB |
ok |
22 |
Correct |
1 ms |
4956 KB |
ok |
23 |
Correct |
1 ms |
4956 KB |
ok |
24 |
Correct |
2 ms |
5120 KB |
ok |
25 |
Correct |
2 ms |
4956 KB |
ok |
26 |
Correct |
1 ms |
4956 KB |
ok |
27 |
Correct |
1 ms |
5208 KB |
ok |
28 |
Correct |
1 ms |
5060 KB |
ok |
29 |
Correct |
2 ms |
4952 KB |
ok |
30 |
Correct |
3 ms |
5212 KB |
ok |
31 |
Correct |
2 ms |
5212 KB |
ok |
32 |
Correct |
2 ms |
5212 KB |
ok |
33 |
Correct |
2 ms |
5212 KB |
ok |
34 |
Correct |
3 ms |
5212 KB |
ok |
35 |
Correct |
3 ms |
5212 KB |
ok |
36 |
Correct |
2 ms |
5212 KB |
ok |
37 |
Correct |
2 ms |
5212 KB |
ok |
38 |
Correct |
2 ms |
5212 KB |
ok |
39 |
Correct |
2 ms |
5260 KB |
ok |
40 |
Correct |
2 ms |
5208 KB |
ok |
41 |
Correct |
2 ms |
5212 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
ok |
2 |
Correct |
2 ms |
4952 KB |
ok |
3 |
Correct |
1 ms |
4956 KB |
ok |
4 |
Correct |
1 ms |
4956 KB |
ok |
5 |
Correct |
1 ms |
4956 KB |
ok |
6 |
Correct |
1 ms |
4956 KB |
ok |
7 |
Correct |
1 ms |
4956 KB |
ok |
8 |
Correct |
1 ms |
4952 KB |
ok |
9 |
Correct |
1 ms |
4956 KB |
ok |
10 |
Correct |
1 ms |
4956 KB |
ok |
11 |
Correct |
1 ms |
4956 KB |
ok |
12 |
Correct |
2 ms |
4956 KB |
ok |
13 |
Correct |
1 ms |
4956 KB |
ok |
14 |
Correct |
1 ms |
4956 KB |
ok |
15 |
Correct |
2 ms |
4956 KB |
ok |
16 |
Correct |
1 ms |
4952 KB |
ok |
17 |
Correct |
1 ms |
4952 KB |
ok |
18 |
Correct |
1 ms |
4952 KB |
ok |
19 |
Correct |
1 ms |
4956 KB |
ok |
20 |
Correct |
2 ms |
4956 KB |
ok |
21 |
Correct |
1 ms |
4956 KB |
ok |
22 |
Correct |
1 ms |
4956 KB |
ok |
23 |
Correct |
1 ms |
4956 KB |
ok |
24 |
Correct |
2 ms |
5120 KB |
ok |
25 |
Correct |
2 ms |
4956 KB |
ok |
26 |
Correct |
1 ms |
4956 KB |
ok |
27 |
Correct |
1 ms |
5208 KB |
ok |
28 |
Correct |
1 ms |
5060 KB |
ok |
29 |
Correct |
2 ms |
4952 KB |
ok |
30 |
Correct |
3 ms |
5212 KB |
ok |
31 |
Correct |
2 ms |
5212 KB |
ok |
32 |
Correct |
2 ms |
5212 KB |
ok |
33 |
Correct |
2 ms |
5212 KB |
ok |
34 |
Correct |
3 ms |
5212 KB |
ok |
35 |
Correct |
3 ms |
5212 KB |
ok |
36 |
Correct |
2 ms |
5212 KB |
ok |
37 |
Correct |
2 ms |
5212 KB |
ok |
38 |
Correct |
2 ms |
5212 KB |
ok |
39 |
Correct |
2 ms |
5260 KB |
ok |
40 |
Correct |
2 ms |
5208 KB |
ok |
41 |
Correct |
2 ms |
5212 KB |
ok |
42 |
Correct |
1137 ms |
8348 KB |
ok |
43 |
Correct |
1491 ms |
8840 KB |
ok |
44 |
Correct |
1121 ms |
9044 KB |
ok |
45 |
Correct |
1099 ms |
8860 KB |
ok |
46 |
Correct |
1481 ms |
9048 KB |
ok |
47 |
Correct |
1086 ms |
9044 KB |
ok |
48 |
Correct |
1075 ms |
8972 KB |
ok |
49 |
Correct |
1458 ms |
8848 KB |
ok |
50 |
Correct |
1494 ms |
9052 KB |
ok |
51 |
Correct |
1474 ms |
8840 KB |
ok |
52 |
Correct |
1481 ms |
8840 KB |
ok |
53 |
Correct |
1483 ms |
9044 KB |
ok |
54 |
Correct |
1489 ms |
9044 KB |
ok |
55 |
Correct |
1484 ms |
8836 KB |
ok |
56 |
Correct |
1460 ms |
8840 KB |
ok |
57 |
Correct |
1458 ms |
8836 KB |
ok |
58 |
Correct |
1474 ms |
8836 KB |
ok |
59 |
Correct |
1103 ms |
9044 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4956 KB |
ok |
2 |
Correct |
2 ms |
4952 KB |
ok |
3 |
Correct |
1 ms |
4956 KB |
ok |
4 |
Correct |
1 ms |
4956 KB |
ok |
5 |
Correct |
1 ms |
4956 KB |
ok |
6 |
Correct |
1 ms |
4956 KB |
ok |
7 |
Correct |
1 ms |
5076 KB |
ok |
8 |
Correct |
14 ms |
5468 KB |
ok |
9 |
Correct |
1482 ms |
8348 KB |
ok |
10 |
Runtime error |
280 ms |
74144 KB |
Execution killed with signal 11 |
11 |
Halted |
0 ms |
0 KB |
- |