#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n'
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
typedef long long ll;
using namespace std;
struct seg{
int m1,m2,sum,cnt;
};
const string out[2]={"NO\n","YES\n"};
const ll dx[]={0,1,0,-1,-1,1,1,-1};
const ll dy[]={1,0,-1,0,-1,1,-1,1};
const int mod=998244353;
const int md=1e9+7;
const int mx=2e3+12;
const bool T=0;
int dp[61][61][61][61];
int pref[61][61];
int n;
int get(int i,int l,int r){
if(!l)return pref[i][r];
return pref[i][r]-pref[i][l-1];
}
int biggest_stadium(int N, vector<vector<int>> a) {
n = N;
if (n > 30) {
return 0;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
pref[i][j] = a[i][j];
if (j)pref[i][j] += pref[i][j - 1];
}
}
int ans=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
for(int l=0;l<n;l++){
for(int r=0;r<n;r++){
dp[i][j][l][r]=-1e9;
}
}
}
}
for(int i=0;i<n;i++){
for(int l=0;l<n;l++){
for(int r=l;r<n;r++){
if(a[i][r])break;
dp[i][i][l][r]=r-l+1;
}
}
}
for(int len=2;len<=n;len++){
for(int i=0;i+len-1<=n;i++){
int j=i+len-1;
for(int len=1;len<=n;len++){
for(int l=0;l+len-1<=n;l++){
int r=l+len-1;
if(!get(i,l,r)){
for(int tl=l;tl>=0;tl--){
for(int tr=r;tr<n;tr++){
dp[i][j][l][r]=max(dp[i][j][l][r], dp[i+1][j][tl][tr] + r-l+1);
}
}
}
if(!get(j,l,r)){
for(int tl=l;tl>=0;tl--){
for(int tr=r;tr<n;tr++){
dp[i][j][l][r]=max(dp[i][j][l][r], dp[i+1][j][tl][tr] + r-l+1);
}
}
}
ans=max(ans,dp[i][j][l][r]);
}
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
ok |
2 |
Incorrect |
1 ms |
2392 KB |
wrong |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
ok |
2 |
Incorrect |
1 ms |
2392 KB |
wrong |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
ok |
2 |
Incorrect |
1 ms |
2392 KB |
wrong |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
ok |
2 |
Incorrect |
1 ms |
2392 KB |
wrong |
3 |
Halted |
0 ms |
0 KB |
- |