QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#699743#9224. Express EvictionRico64WA 1ms3624kbC++231.4kb2024-11-02 10:34:052024-11-02 10:34:06

Judging History

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

  • [2024-11-02 10:34:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3624kb
  • [2024-11-02 10:34:05]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'