답안 #841909

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
841909 2023-09-02T08:22:09 Z flashmt 축구 경기장 (IOI23_soccer) C++17
61 / 100
348 ms 47952 KB
#include "soccer.h"
// #include "Debug.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 33;

int f[N][N][N][N];

int isBad(vector<pair<int, int>> a)
{
  int len = size(a);
  for (int i = 0; i < len; i++)
    for (int j = i + 1; j < len; j++)
    {
      auto [l, r] = a[i];
      auto [ll, rr] = a[j];
      int intersect = min(r, rr) - max(l, ll);
      if (intersect >= 0 && intersect < min(r - l, rr - ll))
        return 1;
    }
  return 0;
}

void update(int &x, int y)
{
  x = max(x, y);
}

int biggest_stadium(int n, std::vector<std::vector<int>> a)
{
  int area = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      area += 1 - a[i][j];

  int canUseAll = 1;

  vector<vector<pair<int, int>>> rows(n);
  vector<pair<int, int>> allRows;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n;)
      if (a[i][j]) j++;
      else
      {
        int jj = j + 1;
        while (jj < n && !a[i][jj])
          jj++;
        rows[i].push_back({j, jj - 1});
        j = jj;
      }

    if (size(rows[i]) > 1) canUseAll = 0;
    else if (size(rows[i]) == 1) allRows.push_back(rows[i][0]);
  }

  vector<vector<pair<int, int>>> cols(n);
  vector<pair<int, int>> allCols;
  for (int j = 0; j < n; j++)
  {
    for (int i = 0; i < n;)
      if (a[i][j]) i++;
      else
      {
        int ii = i + 1;
        while (ii < n && !a[ii][j])
          ii++;
        cols[j].push_back({i, ii - 1});
        i = ii;
      }

    if (size(cols[j]) > 1) canUseAll = 0;
    else if (size(cols[j]) == 1) allCols.push_back(cols[j][0]);
  }

  canUseAll &= !isBad(allRows) && !isBad(allCols);
  if (canUseAll)
    return area;

  if (n <= N)
  {
    for (int i = 0; i < n; i++)
      for (auto [l, r] : rows[i])
        f[i][i][l][r] = r - l + 1;

    int ans = 0;
    for (int len = 1; len < n; len++)
      for (int i = 0; i + len <= n; i++)
        for (int j = 0; j < n; j++)
          for (int jj = j; jj < n; jj++)
          {
            int ii = i + len - 1;
            if (!f[i][ii][j][jj])
              continue;

            ans = max(ans, f[i][ii][j][jj]);

            if (i)
            {
              for (auto [l, r] : rows[i - 1])
              {
                int k = max(j, l), kk = min(jj, r);
                if (k <= kk)
                  update(f[i - 1][ii][k][kk], f[i][ii][j][jj] + kk - k + 1);
              }
            }

            if (ii + 1 < n)
            {
              for (auto [l, r] : rows[ii + 1])
              {
                int k = max(j, l), kk = min(jj, r);
                if (k <= kk)
                  update(f[i][ii + 1][k][kk], f[i][ii][j][jj] + kk - k + 1);
              }
            }
          }

    for (int j = 0; j < n; j++)
      for (int jj = j; jj < n; jj++)
        ans = max(ans, f[0][n - 1][j][jj]);

    return ans;
  }

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 344 KB ok
3 Correct 0 ms 344 KB ok
4 Correct 0 ms 344 KB ok
5 Correct 0 ms 344 KB ok
6 Correct 1 ms 2392 KB ok
7 Partially correct 1 ms 344 KB partial
8 Partially correct 15 ms 2392 KB partial
9 Partially correct 246 ms 32084 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 344 KB ok
3 Correct 1 ms 2392 KB ok
4 Correct 1 ms 2392 KB ok
5 Correct 1 ms 2396 KB ok
6 Correct 1 ms 2392 KB ok
7 Correct 1 ms 2392 KB ok
8 Correct 0 ms 344 KB ok
9 Correct 0 ms 348 KB ok
10 Correct 1 ms 2392 KB ok
11 Correct 0 ms 2392 KB ok
12 Correct 0 ms 2396 KB ok
13 Correct 0 ms 344 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 344 KB ok
4 Correct 1 ms 2392 KB ok
5 Correct 1 ms 2392 KB ok
6 Correct 1 ms 2396 KB ok
7 Correct 1 ms 2392 KB ok
8 Correct 1 ms 2392 KB ok
9 Correct 0 ms 344 KB ok
10 Correct 0 ms 348 KB ok
11 Correct 1 ms 2392 KB ok
12 Correct 0 ms 2392 KB ok
13 Correct 0 ms 2396 KB ok
14 Correct 0 ms 344 KB ok
15 Correct 1 ms 2392 KB ok
16 Correct 0 ms 2392 KB ok
17 Correct 1 ms 2392 KB ok
18 Correct 0 ms 2396 KB ok
19 Correct 0 ms 2392 KB ok
20 Correct 0 ms 344 KB ok
21 Correct 0 ms 344 KB ok
22 Correct 1 ms 2392 KB ok
23 Correct 0 ms 2392 KB ok
24 Correct 1 ms 2392 KB ok
25 Correct 1 ms 2392 KB ok
26 Correct 0 ms 2392 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 344 KB ok
4 Correct 0 ms 344 KB ok
5 Correct 0 ms 344 KB ok
6 Correct 1 ms 2392 KB ok
7 Correct 1 ms 2392 KB ok
8 Correct 1 ms 2396 KB ok
9 Correct 1 ms 2392 KB ok
10 Correct 1 ms 2392 KB ok
11 Correct 0 ms 344 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 1 ms 2392 KB ok
14 Correct 0 ms 2392 KB ok
15 Correct 0 ms 2396 KB ok
16 Correct 0 ms 344 KB ok
17 Correct 1 ms 2392 KB ok
18 Correct 0 ms 2392 KB ok
19 Correct 1 ms 2392 KB ok
20 Correct 0 ms 2396 KB ok
21 Correct 0 ms 2392 KB ok
22 Correct 0 ms 344 KB ok
23 Correct 0 ms 344 KB ok
24 Correct 1 ms 2392 KB ok
25 Correct 0 ms 2392 KB ok
26 Correct 1 ms 2392 KB ok
27 Correct 1 ms 2392 KB ok
28 Correct 0 ms 2392 KB ok
29 Correct 0 ms 2392 KB ok
30 Correct 1 ms 4700 KB ok
31 Correct 1 ms 4440 KB ok
32 Correct 1 ms 4440 KB ok
33 Correct 1 ms 4440 KB ok
34 Correct 1 ms 344 KB ok
35 Correct 0 ms 344 KB ok
36 Correct 1 ms 2396 KB ok
37 Correct 1 ms 4440 KB ok
38 Correct 1 ms 4440 KB ok
39 Correct 1 ms 4696 KB ok
40 Correct 1 ms 4440 KB ok
41 Correct 1 ms 4696 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 344 KB ok
4 Correct 0 ms 344 KB ok
5 Correct 0 ms 344 KB ok
6 Correct 1 ms 2392 KB ok
7 Correct 1 ms 2392 KB ok
8 Correct 1 ms 2396 KB ok
9 Correct 1 ms 2392 KB ok
10 Correct 1 ms 2392 KB ok
11 Correct 0 ms 344 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 1 ms 2392 KB ok
14 Correct 0 ms 2392 KB ok
15 Correct 0 ms 2396 KB ok
16 Correct 0 ms 344 KB ok
17 Correct 1 ms 2392 KB ok
18 Correct 0 ms 2392 KB ok
19 Correct 1 ms 2392 KB ok
20 Correct 0 ms 2396 KB ok
21 Correct 0 ms 2392 KB ok
22 Correct 0 ms 344 KB ok
23 Correct 0 ms 344 KB ok
24 Correct 1 ms 2392 KB ok
25 Correct 0 ms 2392 KB ok
26 Correct 1 ms 2392 KB ok
27 Correct 1 ms 2392 KB ok
28 Correct 0 ms 2392 KB ok
29 Correct 0 ms 2392 KB ok
30 Correct 1 ms 4700 KB ok
31 Correct 1 ms 4440 KB ok
32 Correct 1 ms 4440 KB ok
33 Correct 1 ms 4440 KB ok
34 Correct 1 ms 344 KB ok
35 Correct 0 ms 344 KB ok
36 Correct 1 ms 2396 KB ok
37 Correct 1 ms 4440 KB ok
38 Correct 1 ms 4440 KB ok
39 Correct 1 ms 4696 KB ok
40 Correct 1 ms 4440 KB ok
41 Correct 1 ms 4696 KB ok
42 Partially correct 16 ms 2904 KB partial
43 Partially correct 17 ms 3416 KB partial
44 Partially correct 15 ms 2396 KB partial
45 Partially correct 15 ms 2392 KB partial
46 Partially correct 15 ms 2648 KB partial
47 Partially correct 15 ms 2468 KB partial
48 Correct 17 ms 2392 KB ok
49 Partially correct 23 ms 2456 KB partial
50 Partially correct 19 ms 3420 KB partial
51 Partially correct 16 ms 2712 KB partial
52 Partially correct 20 ms 2396 KB partial
53 Partially correct 18 ms 2392 KB partial
54 Partially correct 19 ms 2392 KB partial
55 Partially correct 17 ms 2396 KB partial
56 Partially correct 17 ms 2396 KB partial
57 Partially correct 15 ms 2392 KB partial
58 Partially correct 15 ms 2392 KB partial
59 Partially correct 17 ms 2468 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 344 KB ok
4 Correct 0 ms 344 KB ok
5 Correct 0 ms 344 KB ok
6 Correct 0 ms 344 KB ok
7 Correct 1 ms 2392 KB ok
8 Partially correct 1 ms 344 KB partial
9 Partially correct 15 ms 2392 KB partial
10 Partially correct 246 ms 32084 KB partial
11 Correct 1 ms 2392 KB ok
12 Correct 1 ms 2392 KB ok
13 Correct 1 ms 2396 KB ok
14 Correct 1 ms 2392 KB ok
15 Correct 1 ms 2392 KB ok
16 Correct 0 ms 344 KB ok
17 Correct 0 ms 348 KB ok
18 Correct 1 ms 2392 KB ok
19 Correct 0 ms 2392 KB ok
20 Correct 0 ms 2396 KB ok
21 Correct 0 ms 344 KB ok
22 Correct 1 ms 2392 KB ok
23 Correct 0 ms 2392 KB ok
24 Correct 1 ms 2392 KB ok
25 Correct 0 ms 2396 KB ok
26 Correct 0 ms 2392 KB ok
27 Correct 0 ms 344 KB ok
28 Correct 0 ms 344 KB ok
29 Correct 1 ms 2392 KB ok
30 Correct 0 ms 2392 KB ok
31 Correct 1 ms 2392 KB ok
32 Correct 1 ms 2392 KB ok
33 Correct 0 ms 2392 KB ok
34 Correct 0 ms 2392 KB ok
35 Correct 1 ms 4700 KB ok
36 Correct 1 ms 4440 KB ok
37 Correct 1 ms 4440 KB ok
38 Correct 1 ms 4440 KB ok
39 Correct 1 ms 344 KB ok
40 Correct 0 ms 344 KB ok
41 Correct 1 ms 2396 KB ok
42 Correct 1 ms 4440 KB ok
43 Correct 1 ms 4440 KB ok
44 Correct 1 ms 4696 KB ok
45 Correct 1 ms 4440 KB ok
46 Correct 1 ms 4696 KB ok
47 Partially correct 16 ms 2904 KB partial
48 Partially correct 17 ms 3416 KB partial
49 Partially correct 15 ms 2396 KB partial
50 Partially correct 15 ms 2392 KB partial
51 Partially correct 15 ms 2648 KB partial
52 Partially correct 15 ms 2468 KB partial
53 Correct 17 ms 2392 KB ok
54 Partially correct 23 ms 2456 KB partial
55 Partially correct 19 ms 3420 KB partial
56 Partially correct 16 ms 2712 KB partial
57 Partially correct 20 ms 2396 KB partial
58 Partially correct 18 ms 2392 KB partial
59 Partially correct 19 ms 2392 KB partial
60 Partially correct 17 ms 2396 KB partial
61 Partially correct 17 ms 2396 KB partial
62 Partially correct 15 ms 2392 KB partial
63 Partially correct 15 ms 2392 KB partial
64 Partially correct 17 ms 2468 KB partial
65 Partially correct 264 ms 40016 KB partial
66 Partially correct 328 ms 47952 KB partial
67 Partially correct 310 ms 40016 KB partial
68 Partially correct 262 ms 32080 KB partial
69 Partially correct 240 ms 32796 KB partial
70 Partially correct 241 ms 33824 KB partial
71 Partially correct 248 ms 32032 KB partial
72 Partially correct 262 ms 32032 KB partial
73 Correct 269 ms 32080 KB ok
74 Correct 270 ms 32084 KB ok
75 Partially correct 273 ms 32032 KB partial
76 Partially correct 272 ms 47952 KB partial
77 Partially correct 278 ms 47900 KB partial
78 Partially correct 254 ms 35360 KB partial
79 Partially correct 293 ms 33716 KB partial
80 Partially correct 348 ms 33192 KB partial
81 Partially correct 295 ms 32848 KB partial
82 Partially correct 293 ms 33064 KB partial
83 Partially correct 305 ms 38944 KB partial
84 Partially correct 284 ms 31828 KB partial
85 Partially correct 287 ms 32032 KB partial
86 Partially correct 282 ms 32048 KB partial
87 Partially correct 288 ms 32036 KB partial
88 Partially correct 286 ms 32068 KB partial
89 Partially correct 241 ms 32032 KB partial
90 Partially correct 257 ms 32080 KB partial
91 Partially correct 255 ms 32080 KB partial
92 Partially correct 316 ms 37920 KB partial
93 Partially correct 304 ms 38224 KB partial
94 Partially correct 294 ms 35364 KB partial
95 Partially correct 294 ms 35920 KB partial
96 Partially correct 291 ms 35920 KB partial
97 Partially correct 289 ms 35664 KB partial
98 Partially correct 290 ms 33872 KB partial
99 Partially correct 246 ms 35876 KB partial
100 Partially correct 235 ms 32036 KB partial
101 Partially correct 258 ms 31872 KB partial
102 Partially correct 242 ms 32024 KB partial
103 Partially correct 243 ms 32080 KB partial
104 Partially correct 238 ms 32092 KB partial
105 Partially correct 238 ms 32028 KB partial
106 Partially correct 238 ms 32100 KB partial
107 Partially correct 240 ms 32032 KB partial
108 Partially correct 263 ms 38168 KB partial
109 Partially correct 255 ms 37656 KB partial