QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#665542#5549. Game Showkai824#WA 1ms3692kbC++203.2kb2024-10-22 13:57:072024-10-22 13:57:14

Judging History

你现在查看的是最新测评结果

  • [2024-10-22 13:57:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3692kb
  • [2024-10-22 13:57:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9 + 20;
const int MAX_N = 120;

int dp[MAX_N][MAX_N * 3][MAX_N][4][5];
bool can[3][MAX_N];

int main() {
  ios_base::sync_with_stdio(false);cin.tie(0);
  int n, k;
  cin >> n >> k;
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = 1; j <= n; j++) {
      char c;
      cin >> c;
      can[i][j] = (c == '.');
      cnt += can[i][j];
    }
  }
  if (cnt < k) {
    cout << -1;
    return 0;
  }
  int res = 1;
  dp[1][0][0][0][3] = INF;
  for (int i = 1; i <= n + 1; i++) {
    for (int j = 0; j <= k; j++) {
      for (int p = 0; p <= max(0, i - 2); p++) {
        for (int x = 0; x < 4; x++) {
          for (int y = 0; y < 5; y++) {
            if (dp[i][j][p][x][y] == 0) {
              continue;
            }
            cout << i << " " << j << " " << p << " " << x << " " << y << " " << dp[i][j][p][x][y] << '\n';
            if (i == n + 1) {
              if (j == k) {
                res = max(res, dp[i][j][p][x][y]);
              }
              continue;
            }
            for (int d = 0; d < 5; d++) {
              if (0 <= d && d <= 2 && !can[d][i]) {
                continue;
              }
              if (d == 3 && (!can[0][i] || !can[2][i])) {
                continue;
              }
              int ni, nj, np, nx, ny;
              ni = i + 1;
              ny = d;
              if (0 <= y && y <= 3) {
                np = i - 1;
                nx = y;
              }
              else {
                np = p;
                nx = x;
              }
              if (0 <= d && d <= 2) {
                nj = j + 1;
              }
              if (d == 3) {
                nj = j + 2;
              }
              if (d == 4) {
                nj = j;
              }
              if (nj > k) {
                continue;
              }
              int cost = INF;
              if (d == 3) {
                cost = min(cost, 4);
              }
              for (int e = 0; e < 3; e++) {
                if ((0 <= d && d <= 2) && (e != d)) {
                  continue;
                }
                if (d == 3 && e == 1) {
                  continue;
                }
                if (d == 4) {
                  continue;
                }
                if (p > 0) {
                  if (0 <= x && x <= 2) {
                    cost = min(cost, (e - x) * (e - x) + (i - p) * (i - p));
                  }
                  if (x == 3) {
                    cost = min(cost, (e - 0) * (e - 0) + (i - p) * (i - p));
                    cost = min(cost, (e - 2) * (e - 2) + (i - p) * (i - p));
                  }
                }
                if (0 <= y && y <= 2) {
                  cost = min(cost, (e - y) * (e - y) + 1);
                }
                if (y == 3) {
                  cost = min(cost, (e - 0) * (e - 0) + 1);
                  cost = min(cost, (e - 2) * (e - 2) + 1);
                }
              }
              dp[ni][nj][np][nx][ny] = max(dp[ni][nj][np][nx][ny], min(dp[i][j][p][x][y], cost));
            }
          }
        }
      }
    }
  }
  long double root = sqrtl(res);
  cout << fixed << setprecision(10) << root;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3692kb

input:

4 4
2 3 -4 3
1 2 7 -1
1 3
3 1
1 4
1 1

output:

-1

result:

wrong answer 1st lines differ - expected: '5', found: '-1'