#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 long long ll;
typedef pair<int,int> ii;
const int MAXN = 2000;
int f[MAXN][MAXN];
int n;
int left(int i, int p) {
dforn(j,p+1) if(f[i][j]==1) return j;
return -1;
}
int right(int i, int p) {
forsn(j,p,n) if(f[i][j]==1) return j;
return n;
}
pair<ll,ii> solve(int l, int r, int p) {
if(l>r) return {0LL,{-1,n}};
auto calculate = [&](pair<int,ii> prev, int i) {
auto [val,range] = prev;
int mini = max(range.fst, left(i,p)), maxi = min(range.snd, right(i,p));
return (pair<ll,ii>){val+maxi-mini-1,{mini,maxi}};
};
return max(calculate(solve(l+1,r,p),l),calculate(solve(l,r-1,p),r));
}
int biggest_stadium(int N, vector<vector<int>> F) {
n=N;
forn(i,n) forn(j,n) {
f[i][j]=F[i][j];
}
ll ans = 0LL;
forn(i,n) {
ll curr = solve(0,n-1,i).fst;
ans=max(ans,curr);
}
return int(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
436 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Execution timed out |
4527 ms |
2652 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
436 KB |
ok |
3 |
Correct |
1 ms |
504 KB |
ok |
4 |
Correct |
1 ms |
344 KB |
ok |
5 |
Partially correct |
1 ms |
348 KB |
partial |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
1 ms |
348 KB |
ok |
8 |
Correct |
1 ms |
344 KB |
ok |
9 |
Correct |
1 ms |
600 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Partially correct |
0 ms |
348 KB |
partial |
12 |
Partially correct |
0 ms |
348 KB |
partial |
13 |
Correct |
1 ms |
348 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
1 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
436 KB |
ok |
4 |
Correct |
1 ms |
504 KB |
ok |
5 |
Correct |
1 ms |
344 KB |
ok |
6 |
Partially correct |
1 ms |
348 KB |
partial |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
1 ms |
348 KB |
ok |
9 |
Correct |
1 ms |
344 KB |
ok |
10 |
Correct |
1 ms |
600 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Partially correct |
0 ms |
348 KB |
partial |
13 |
Partially correct |
0 ms |
348 KB |
partial |
14 |
Correct |
1 ms |
348 KB |
ok |
15 |
Correct |
1 ms |
344 KB |
ok |
16 |
Correct |
1 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
0 ms |
348 KB |
partial |
20 |
Incorrect |
0 ms |
348 KB |
wrong |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
1 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
436 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
1 ms |
504 KB |
ok |
7 |
Correct |
1 ms |
344 KB |
ok |
8 |
Partially correct |
1 ms |
348 KB |
partial |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
1 ms |
348 KB |
ok |
11 |
Correct |
1 ms |
344 KB |
ok |
12 |
Correct |
1 ms |
600 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Partially correct |
0 ms |
348 KB |
partial |
15 |
Partially correct |
0 ms |
348 KB |
partial |
16 |
Correct |
1 ms |
348 KB |
ok |
17 |
Correct |
1 ms |
344 KB |
ok |
18 |
Correct |
1 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Partially correct |
0 ms |
348 KB |
partial |
22 |
Incorrect |
0 ms |
348 KB |
wrong |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
1 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
436 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
1 ms |
504 KB |
ok |
7 |
Correct |
1 ms |
344 KB |
ok |
8 |
Partially correct |
1 ms |
348 KB |
partial |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
1 ms |
348 KB |
ok |
11 |
Correct |
1 ms |
344 KB |
ok |
12 |
Correct |
1 ms |
600 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Partially correct |
0 ms |
348 KB |
partial |
15 |
Partially correct |
0 ms |
348 KB |
partial |
16 |
Correct |
1 ms |
348 KB |
ok |
17 |
Correct |
1 ms |
344 KB |
ok |
18 |
Correct |
1 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Partially correct |
0 ms |
348 KB |
partial |
22 |
Incorrect |
0 ms |
348 KB |
wrong |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
1 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
436 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Execution timed out |
4527 ms |
2652 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |