QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#608149 | #9224. Express Eviction | maxplus | WA | 0ms | 3544kb | C++20 | 998b | 2024-10-03 19:06:22 | 2024-10-03 19:06:23 |
Judging History
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];
}
Details
Tip: Click on the bar to expand more detailed information
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'