/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 575ms 12.438 MiB
#2 Accepted 587ms 12.383 MiB
#3 Accepted 562ms 12.223 MiB
#4 Wrong Answer 562ms 12.434 MiB
#5 Wrong Answer 565ms 12.328 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));
vector<pair<int, vector<pair<int, int>>>> can;

void dfs(int L = 0) {
  if (L >= (int) can.size()) {
    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;
    return;
  }
  dfs(L + 1);
  const auto& [t, v] = can[L];
  bool foo = 1;
  for (auto [i, j] : v) {
    foo &= !g[i][j];
  }
  if (foo) {
    type[t] += 1;
    for (auto [i, j] : v) {
      g[i][j] = 1;
    }
    dfs(L + 1);
    type[t] -= 1;
    for (auto [i, j] : v) {
      g[i][j] = 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 < 3; i++) {
    for (int j = 0; j < 2; j++) {
      {
        vector<pair<int, int>> a;
        a.emplace_back(i, j);
        a.emplace_back(i, j + 1);
        can.emplace_back(1, a);
      }
      {
        swap(i, j);
        vector<pair<int, int>> a;
        a.emplace_back(i, j);
        a.emplace_back(i + 1, j);
        can.emplace_back(1, a);
        swap(i, j);
      }
    }
    {
      vector<pair<int, int>> a;
      a.emplace_back(i, 0);
      a.emplace_back(i, 1);
      a.emplace_back(i, 2);
      can.emplace_back(2, a);
    }
    {
      vector<pair<int, int>> a;
      a.emplace_back(0, i);
      a.emplace_back(1, i);
      a.emplace_back(2, i);
      can.emplace_back(2, a);
    }
  }
  vector<pair<int, int>> moves = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, 0}};
  auto inside = [&](int i, int j) {
    return min(i, j) >= 0 && max(i, j) < 3;
  };
  for (int d = 0; d < 4; d++) {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        int x = i + moves[d].first;
        int y = j + moves[d].second;
        int u = i + moves[d + 1].first;
        int v = i + moves[d + 1].second;
        if (inside(x, y) && inside(u, v)) {
          vector<pair<int, int>> a;
          a.emplace_back(i, j);
          a.emplace_back(x, y);
          a.emplace_back(u, v);
          can.emplace_back(3, a);
        }
      }
    }
  }
  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-07 00:09:06
Judged At
2024-11-11 03:31:19
Judged By
Score
3
Total Time
587ms
Peak Memory
12.438 MiB