QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#699743 | #9224. Express Eviction | Rico64 | WA | 1ms | 3624kb | C++23 | 1.4kb | 2024-11-02 10:34:05 | 2024-11-02 10:34:06 |
Judging History
answer
#include <iostream>
#include <queue>
const int dxs[] {-1, 0, 0, 1};
const int dys[] {0, -1, 1, 0};
using namespace std;
int xl, yl;
bool grid[50][50];
int get(int x, int y) {
if (x < 0 || x >= xl || y < 0 || y >= yl) return 0;
return grid[x][y];
}
int main() {
cin >> xl >> yl;
for (int x = 0; x < xl; ++x) {
string s;
cin >> s;
for (int y = 0; y < yl; ++y) {
grid[x][y] = s[y] == '#';
}
}
priority_queue<pair<int,pair<int, int>>> pq;
pq.push({-get(0, 0), {0, 0}});
bool trav[xl + 1][yl + 1];
for (int x = 0; x <= xl; ++x) fill(trav[x], trav[x] + (yl + 1), false);
while (!pq.empty()) {
pair<int,pair<int, int>> cur = pq.top(); pq.pop();
int x = cur.second.first;
int y = cur.second.second;
int cost = cur.first;
if (x < 0 || x >= xl + 1 || y < 0 || y >= yl + 1) continue;
if (trav[x][y]) continue;
trav[x][y] = true;
if (x == xl && y == yl) {
cout << -cost << endl;
return 0;
}
pq.push({cost - get(x + 1, y) - get(x + 1, y - 1), {x + 1, y}});
pq.push({cost - get(x, y + 1) - get(x - 1, y + 1), {x, y + 1}});
pq.push({cost - get(x - 2, y) - get(x - 2, y - 1), {x - 1, y}});
pq.push({cost - get(x, y - 2) - get(x - 1, y - 2), {x, y - 1}});
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
4 6 .##... .#.... ##.... ....#.
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3624kb
input:
20 30 ...########################### #..########################### ...########################### ...########################### .############################# ...########################### ...########################### #..########################### ...########################### ..#...............
output:
12
result:
wrong answer 1st numbers differ - expected: '11', found: '12'