QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#608149#9224. Express EvictionmaxplusWA 0ms3544kbC++20998b2024-10-03 19:06:222024-10-03 19:06:23

Judging History

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

  • [2024-10-03 19:06:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3544kb
  • [2024-10-03 19:06:22]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 64;

bool b[N][N];
int d[N][N], h, w;

int chk(int i, int j) { return i >= 0 && j >= 0 && i <= h && j <= w; }
int get(int i, int j) { return chk(i, j) && b[i][j]; }

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> h >> w;
  for (int i = 0; i < h; ++i) if (string s; cin >> s, 1)
  for (int j = 0; j < w; ++j) b[i][j] = s[j] == '#';
  fill(d[0] + 1, d[N], 1e9);
  priority_queue pq{greater{}, vector<int>{{}}};
  while (pq.size()) {
    auto t = pq.top(); pq.pop();
    int cd = t >> 12, i = t >> 6 & 63, j = t & 63;
    if (cd != d[i][j]) continue;
    for (auto di: {-1, 0, 1})
    for (auto dj: {-1, 0, 1}) if ((!di ^ !dj) && chk(i + di, j + dj))
    if (auto t = cd + get(i + di - (di < 1), j + dj - (dj < 1)) + get(i + di - (di < 0), j + dj - (dj < 0)); d[i + di][j + dj] > t) {
      pq.push((d[i + di][j + dj] = t) << 12 | i + di << 6 | j + dj);
    }
  }
  cout << d[h][w] + b[0][0];
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3544kb

input:

4 6
.##...
.#....
##....
....#.

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3544kb

input:

20 30
...###########################
#..###########################
...###########################
...###########################
.#############################
...###########################
...###########################
#..###########################
...###########################
..#...............

output:

12

result:

wrong answer 1st numbers differ - expected: '11', found: '12'