답안 #840705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
840705 2023-08-31T16:05:36 Z danikoynov 축구 경기장 (IOI23_soccer) C++17
48 / 100
4500 ms 6276 KB
#include "soccer.h"
#include <bits/stdc++.h>

using namespace std;

const int maxn = 510;
int a[maxn][maxn], bef[maxn][maxn], aft[maxn][maxn];
int dp[maxn][maxn];

int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
    for (int i = 0; i < N; i ++)
        for (int j = 0; j < N; j ++)
    {
        a[i + 1][j + 1] = F[i][j];
    }

    for (int i = 1; i <= N; i ++)
    {
        for (int j = 1; j <= N; j ++)
        {
            if (a[i][j] == 1)
                bef[i][j] = j;
            else
                bef[i][j] = bef[i][j - 1];
        }

        aft[i][N + 1] = N + 1;
        for (int j = N; j > 0; j --)
        {
            if (a[i][j] == 1)
                aft[i][j] = j;
            else
                aft[i][j] = aft[i][j + 1];
        }
    }

    int ans = 0;
    for (int col = 1; col <= N; col ++)
            ///int col = 5;
    {
        for (int i = 1; i <= N; i ++)
            for (int j = 1; j <= N; j ++)
            dp[i][j] = 0;

        for (int len = 1; len <= N; len ++)
        {
            for (int i = 1; i <= N - len + 1; i ++)
            {
                int j = i + len - 1;


                bool done = false;
                int left_width = N, right_width = N;
                for (int k = i; k <= j; k ++)
                {
                    if (a[k][col] == 1)
                    {
                        done = true;
                        break;
                    }

                    left_width = min(left_width, col - bef[k][col]);
                    right_width = min(right_width, aft[k][col] - col);
                }

                if (done)
                    continue;
                    int base_area = (j - i + 1) * (left_width + right_width - 1);
                dp[i][j] = base_area;

                if (left_width != col)
                {
                    vector < int > split;
                    split.push_back(i - 1);
                    for (int k = i; k <= j; k ++)
                    {
                        if (bef[k][col] == col - left_width)
                            split.push_back(k);
                    }
                    split.push_back(j + 1);

                    for (int d = 1; d < (int)(split.size()); d ++)
                    {
                        ///cout << "check " << split[d - 1] + 1 << " " << split[d] - 1 << endl;
                        int rem_area = (split[d] - split[d - 1] - 1) * (left_width + right_width - 1);
                        dp[i][j] = max(dp[i][j], dp[split[d - 1] + 1][split[d] - 1] - rem_area + base_area);
                    }
                }

                if (right_width != N + 1 - col)
                {
                    vector < int > split;
                                        split.push_back(i - 1);
                    for (int k = i; k <= j; k ++)
                    {
                        if (aft[k][col] == col + right_width)
                            split.push_back(k);
                    }
                    split.push_back(j + 1);

                    for (int d = 1; d < (int)(split.size()); d ++)
                    {
                        int rem_area = (split[d] - split[d - 1] - 1) * (left_width + right_width - 1);
                        dp[i][j] = max(dp[i][j], dp[split[d - 1] + 1][split[d] - 1] - rem_area + base_area);
                    }
                }
                ans = max(ans, dp[i][j]);
                ///cout << i << " : " << j << " = " << dp[i][j] << endl;
            }

        }
    }
    return ans;
}

Compilation message

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:67:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   67 |                 if (done)
      |                 ^~
soccer.cpp:69:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   69 |                     int base_area = (j - i + 1) * (left_width + right_width - 1);
      |                     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB ok
2 Correct 0 ms 340 KB ok
3 Correct 0 ms 340 KB ok
4 Correct 0 ms 340 KB ok
5 Correct 1 ms 212 KB ok
6 Correct 0 ms 340 KB ok
7 Correct 92 ms 1196 KB ok
8 Execution timed out 4580 ms 6228 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB ok
2 Correct 0 ms 340 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 0 ms 340 KB ok
5 Correct 1 ms 212 KB ok
6 Correct 0 ms 340 KB ok
7 Correct 0 ms 340 KB ok
8 Correct 0 ms 212 KB ok
9 Correct 0 ms 212 KB ok
10 Correct 1 ms 340 KB ok
11 Correct 1 ms 340 KB ok
12 Correct 1 ms 212 KB ok
13 Correct 1 ms 340 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ok
2 Correct 0 ms 340 KB ok
3 Correct 0 ms 340 KB ok
4 Correct 0 ms 212 KB ok
5 Correct 0 ms 340 KB ok
6 Correct 1 ms 212 KB ok
7 Correct 0 ms 340 KB ok
8 Correct 0 ms 340 KB ok
9 Correct 0 ms 212 KB ok
10 Correct 0 ms 212 KB ok
11 Correct 1 ms 340 KB ok
12 Correct 1 ms 340 KB ok
13 Correct 1 ms 212 KB ok
14 Correct 1 ms 340 KB ok
15 Correct 1 ms 340 KB ok
16 Correct 0 ms 340 KB ok
17 Correct 0 ms 340 KB ok
18 Correct 0 ms 340 KB ok
19 Correct 1 ms 340 KB ok
20 Correct 0 ms 340 KB ok
21 Correct 0 ms 340 KB ok
22 Correct 0 ms 340 KB ok
23 Correct 0 ms 340 KB ok
24 Correct 0 ms 340 KB ok
25 Correct 1 ms 340 KB ok
26 Correct 0 ms 340 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ok
2 Correct 0 ms 340 KB ok
3 Correct 0 ms 340 KB ok
4 Correct 0 ms 340 KB ok
5 Correct 0 ms 340 KB ok
6 Correct 0 ms 212 KB ok
7 Correct 0 ms 340 KB ok
8 Correct 1 ms 212 KB ok
9 Correct 0 ms 340 KB ok
10 Correct 0 ms 340 KB ok
11 Correct 0 ms 212 KB ok
12 Correct 0 ms 212 KB ok
13 Correct 1 ms 340 KB ok
14 Correct 1 ms 340 KB ok
15 Correct 1 ms 212 KB ok
16 Correct 1 ms 340 KB ok
17 Correct 1 ms 340 KB ok
18 Correct 0 ms 340 KB ok
19 Correct 0 ms 340 KB ok
20 Correct 0 ms 340 KB ok
21 Correct 1 ms 340 KB ok
22 Correct 0 ms 340 KB ok
23 Correct 0 ms 340 KB ok
24 Correct 0 ms 340 KB ok
25 Correct 0 ms 340 KB ok
26 Correct 0 ms 340 KB ok
27 Correct 1 ms 340 KB ok
28 Correct 0 ms 340 KB ok
29 Correct 0 ms 340 KB ok
30 Correct 2 ms 468 KB ok
31 Correct 1 ms 468 KB ok
32 Correct 1 ms 468 KB ok
33 Correct 1 ms 468 KB ok
34 Correct 1 ms 468 KB ok
35 Correct 1 ms 468 KB ok
36 Correct 1 ms 468 KB ok
37 Correct 1 ms 468 KB ok
38 Correct 1 ms 468 KB ok
39 Correct 1 ms 468 KB ok
40 Correct 2 ms 468 KB ok
41 Correct 2 ms 468 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ok
2 Correct 0 ms 340 KB ok
3 Correct 0 ms 340 KB ok
4 Correct 0 ms 340 KB ok
5 Correct 0 ms 340 KB ok
6 Correct 0 ms 212 KB ok
7 Correct 0 ms 340 KB ok
8 Correct 1 ms 212 KB ok
9 Correct 0 ms 340 KB ok
10 Correct 0 ms 340 KB ok
11 Correct 0 ms 212 KB ok
12 Correct 0 ms 212 KB ok
13 Correct 1 ms 340 KB ok
14 Correct 1 ms 340 KB ok
15 Correct 1 ms 212 KB ok
16 Correct 1 ms 340 KB ok
17 Correct 1 ms 340 KB ok
18 Correct 0 ms 340 KB ok
19 Correct 0 ms 340 KB ok
20 Correct 0 ms 340 KB ok
21 Correct 1 ms 340 KB ok
22 Correct 0 ms 340 KB ok
23 Correct 0 ms 340 KB ok
24 Correct 0 ms 340 KB ok
25 Correct 0 ms 340 KB ok
26 Correct 0 ms 340 KB ok
27 Correct 1 ms 340 KB ok
28 Correct 0 ms 340 KB ok
29 Correct 0 ms 340 KB ok
30 Correct 2 ms 468 KB ok
31 Correct 1 ms 468 KB ok
32 Correct 1 ms 468 KB ok
33 Correct 1 ms 468 KB ok
34 Correct 1 ms 468 KB ok
35 Correct 1 ms 468 KB ok
36 Correct 1 ms 468 KB ok
37 Correct 1 ms 468 KB ok
38 Correct 1 ms 468 KB ok
39 Correct 1 ms 468 KB ok
40 Correct 2 ms 468 KB ok
41 Correct 2 ms 468 KB ok
42 Correct 1589 ms 6276 KB ok
43 Correct 725 ms 6272 KB ok
44 Execution timed out 4517 ms 6168 KB Time limit exceeded
45 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ok
2 Correct 0 ms 340 KB ok
3 Correct 0 ms 340 KB ok
4 Correct 0 ms 340 KB ok
5 Correct 0 ms 340 KB ok
6 Correct 1 ms 212 KB ok
7 Correct 0 ms 340 KB ok
8 Correct 92 ms 1196 KB ok
9 Execution timed out 4580 ms 6228 KB Time limit exceeded
10 Halted 0 ms 0 KB -