/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 338ms 12.359 MiB
#2 Wrong Answer 270ms 12.281 MiB
#3 Accepted 302ms 12.438 MiB
#4 Accepted 280ms 12.629 MiB
#5 Accepted 277ms 12.402 MiB
#6 Accepted 293ms 12.375 MiB
#7 Accepted 271ms 12.43 MiB
#8 Accepted 280ms 12.277 MiB
#9 Accepted 338ms 12.438 MiB
#10 Accepted 268ms 12.324 MiB
#11 Accepted 278ms 12.281 MiB
#12 Accepted 263ms 12.406 MiB
#13 Wrong Answer 269ms 12.488 MiB
#14 Accepted 261ms 12.223 MiB
#15 Accepted 264ms 12.359 MiB
#16 Accepted 272ms 12.434 MiB
#17 Accepted 274ms 12.25 MiB
#18 Accepted 262ms 12.355 MiB
#19 Accepted 262ms 12.422 MiB
#20 Accepted 265ms 12.434 MiB
#21 Wrong Answer 262ms 12.426 MiB
#22 Wrong Answer 264ms 12.566 MiB
#23 Wrong Answer 269ms 12.352 MiB
#24 Accepted 260ms 12.375 MiB
#25 Accepted 262ms 12.348 MiB
#26 Accepted 261ms 12.328 MiB
#27 Accepted 264ms 12.352 MiB
#28 Accepted 265ms 12.332 MiB
#29 Accepted 269ms 12.203 MiB
#30 Accepted 280ms 12.676 MiB
#31 Accepted 270ms 12.43 MiB
#32 Wrong Answer 265ms 12.25 MiB
#33 Accepted 266ms 12.379 MiB
#34 Accepted 265ms 12.379 MiB
#35 Accepted 259ms 12.25 MiB
#36 Accepted 260ms 12.285 MiB
#37 Wrong Answer 267ms 12.434 MiB
#38 Accepted 260ms 12.25 MiB
#39 Accepted 263ms 12.352 MiB

Code


#include <set>
#include <array>
#include <vector>
#include <iostream>

using namespace std;

array<int, 4> type;
set<array<int, 4>> S;
vector g(3, vector<bool> (3));

void dfs(int L = 0) {
  if (L < 4) {
    dfs(L + 1);
    int x = 0, y = 0;
    if (L < 2) {
      y += L;
    } else {
      x += 1;
      y += L - 2;
    }
    if (!g[x][y] && !g[x + 1][y] && !g[x][y + 1]) {
      type[3] += 1;
      g[x][y] = 1;
      g[x + 1][y] = 1;
      g[x][y + 1] = 1;
      dfs(L + 1);
      type[3] -= 1;
      g[x][y] = 0;
      g[x + 1][y] = 0;
      g[x][y + 1] = 0;
    }
    return;
  }
  if (L < 8) {
    dfs(L + 1);
    int x = 0, y = 2;
    if (L < 6) {
      y -= L - 4;
    } else {
      x += 1;
      y -= L - 6;
    }
    if (!g[x][y] && !g[x + 1][y] && !g[x][y - 1]) {
      type[3] += 1;
      g[x][y] = 1;
      g[x + 1][y] = 1;
      g[x][y - 1] = 1;
      dfs(L + 1);
      type[3] -= 1;
      g[x][y] = 0;
      g[x + 1][y] = 0;
      g[x][y - 1] = 0;
    }
    return;
  }
  if (L < 12) {
    dfs(L + 1);
    int x = 2, y = 0;
    if (L < 10) {
      y += L - 8;
    } else {
      x -= 1;
      y += L - 10;
    }
    if (!g[x][y] && !g[x - 1][y] && !g[x][y + 1]) {
      type[3] += 1;
      g[x][y] = 1;
      g[x - 1][y] = 1;
      g[x][y + 1] = 1;
      dfs(L + 1);
      type[3] -= 1;
      g[x][y] = 0;
      g[x - 1][y] = 0;
      g[x][y + 1] = 0;
    }
    return;
  }
  if (L < 16) {
    dfs(L + 1);
    int x = 2, y = 2;
    if (L < 14) {
      y -= L - 12;
    } else {
      x -= 1;
      y -= L - 14;
    }
    if (!g[x][y] && !g[x - 1][y] && !g[x][y - 1]) {
      type[3] += 1;
      g[x][y] = 1;
      g[x - 1][y] = 1;
      g[x][y - 1] = 1;
      dfs(L + 1);
      type[3] -= 1;
      g[x][y] = 0;
      g[x - 1][y] = 0;
      g[x][y - 1] = 0;
    }
    return;
  }
  if (L < 22) {
    dfs(L + 1);
    int x = 0, y = 0;
    if (L < 19) {
      y = L - 16;
    } else {
      x = 1;
      y = L - 19;
    }
    if (!g[x][y] && !g[x + 1][y]) {
      type[1] += 1;
      g[x][y] = 1;
      g[x + 1][y] = 1;
      dfs(L + 1);
      type[1] -= 1;
      g[x][y] = 0;
      g[x + 1][y] = 0;
    }
    return;
  }
  if (L < 28) {
    dfs(L + 1);
    int x = 0, y = 0;
    if (L < 25) {
      x = L - 22;
    } else {
      y = 1;
      x = L - 25;
    }
    if (!g[x][y] && !g[x][y + 1]) {
      type[1] += 1;
      g[x][y] = 1;
      g[x][y + 1] = 1;
      dfs(L + 1);
      type[1] -= 1;
      g[x][y] = 0;
      g[x][y + 1] = 0;
    }
    return;
  }
  if (L < 31) {
    dfs(L + 1);
    int x = 0, y = L - 28;
    if (!g[x][y] && !g[x + 1][y] && !g[x + 2][y]) {
      type[2] += 1;
      g[x][y] = 1;
      g[x + 1][y] = 1;
      g[x + 2][y] = 1;
      dfs(L + 1);
      type[2] -= 1;
      g[x][y] = 0;
      g[x + 1][y] = 0;
      g[x + 2][y] = 0;
    }
    return;
  }
  if (L < 34) {
    dfs(L + 1);
    int x = L - 31, y = 0;
    if (!g[x][y] && !g[x][y + 1] && !g[x][y + 2]) {
      type[2] += 1;
      g[x][y] = 1;
      g[x][y + 1] = 1;
      g[x][y + 2] = 1;
      dfs(L + 1);
      type[2] -= 1;
      g[x][y] = 0;
      g[x][y + 1] = 0;
      g[x][y + 2] = 0;
    }
    return;
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      type[0] += !g[i][j];
    }
  }
  S.insert(type);
  type[0] = 0;
}

const int N = 41;
int f[N + 1][N + 1][N + 1][N + 1];

inline void Max(int& a, int b) {
  a = max(a, b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 0; i < 4; i++) {
    type[i] = 0;
  }
  dfs();
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        for (int l = 0; l < N; l++) {
          Max(f[i + 1][j][k][l], f[i][j][k][l]);
          Max(f[i][j + 1][k][l], f[i][j][k][l]);
          Max(f[i][j][k + 1][l], f[i][j][k][l]);
          Max(f[i][j][k][l + 1], f[i][j][k][l]);
          for (auto [a, b, c, d] : S) {
            if (i + a <= N && j + b <= N && k + c <= N && l + d <= N) {
              Max(f[i + a][j + b][k + c][l + d], f[i][j][k][l] + 1);
            }
          }
        }
      }
    }
  }
  int t;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << "Case " << i << ": " << f[a][b][c][d] << '\n';
  }
  return 0;
}
  

Information

Submit By
Type
Submission
Problem
P1014 FIFA World Cup 2022 Again!
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 23:35:27
Judged At
2024-05-06 23:35:27
Judged By
Score
93
Total Time
338ms
Peak Memory
12.676 MiB