답안 #1008336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1008336 2024-06-26T09:36:49 Z Amr 축구 경기장 (IOI23_soccer) C++17
0 / 100
4500 ms 348 KB
#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
#define F first
#define S second
#define sz size()
#define all(x) (x).begin(), (x).end()
const int N = 32;
ll n;
vector<vector<int> > a;
ll dp[N][N][N][2];
ll pre[N][N];
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
    n = N, a = F;
    for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) pre[i][j] = pre[i][j-1]+a[i-1][j-1];
    //for(int i = 1; i <= n; i++) {for(int j = 1; j <= n;j++) cout << pre[i][j] << " "; cout << endl;}
    // base case
    ll best = 0;
    for(int u = 1; u <= n; u++) for(int v = u; v <= n; u++){
    for(int r = 1; r <= n ;r++) for(int i = 1; i <= n; i++) for(int j = 1; j <= n ;j++) dp[r][i][j][0] = dp[r][i][j][2] = 0;
    for(int r = 1; r <= n; r++)
    for(int i = 1; i <= n; i++) for(int j = i; j <= n ;j++)
    {
        if(i>u||j<v) continue;
        ll cnt = pre[r][j]-pre[r][i-1];
        if(cnt>0) continue;
        dp[r][i][j][0] = j-i+1;
        dp[r][i][j][1] = j-i+1;
       // cout << dp[1][i][j][0] << " ";
    }
    for(int r = 2; r<= n; r++)
    for(int i2 = 1; i2 <= n; i2++)
    {
        for(int j2 = i2; j2 <= n; j2++)
        {
            if(i2>u||j2<v) continue;
            ll cnt = pre[r-1][j2]-pre[r-1][i2-1];
            if(cnt>0) continue;
            for(int i = 1; i <= n; i++)
            {
                for(int j =i ; j <= n; j++)
                {
                    if(i>u||j<v) continue;
                    cnt = pre[r][j]-pre[r][i-1];
                    if(cnt>0) continue;
                  // if(i==2&&j==5&&r==2&&i2==1&&j2==5) cout << dp[r-1][i2][j2][0] << endl;
                    if(i2>=i&&j2<=j) // prev is sub from me
                        {dp[r][i][j][0] = max(dp[r][i][j][0],dp[r-1][i2][j2][0]+j-i+1);
                         dp[r][i][j][1] = max(dp[r][i][j][1],dp[r-1][i2][j2][0]+j-i+1);
                        }
                     if(i2<=i&&j2>=j)
                        dp[r][i][j][1] = max({dp[r][i][j][1],dp[r-1][i2][j2][0]+j-i+1,dp[r-1][i2][j2][1]+j-i+1});
                }
            }
        }
    }
   // cout << dp[2][3][4][1] << endl;
    for(int r = 1; r <= n; r++)
    for(int i = 1; i <= n; i++)
    {
        for(int j = i; j <= n; j++)
        {
            if(i>u||j<v) continue;
            best = max({best,dp[r][i][j][0],dp[r][i][j][1]});
        }
           //if(dp[r][i][j][1]==21) cout<<r << i << " " << j << endl;
    }
    }
    return best;
}
/*
5
0 0 0 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 1 0 0

*/

Compilation message

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:23:119: warning: array subscript 2 is above array bounds of 'll [2]' {aka 'long long int [2]'} [-Warray-bounds]
   23 |     for(int r = 1; r <= n ;r++) for(int i = 1; i <= n; i++) for(int j = 1; j <= n ;j++) dp[r][i][j][0] = dp[r][i][j][2] = 0;
      |                                                                                                          ~~~~~~~~~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4566 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4547 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4547 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4566 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4566 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4566 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4566 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -