QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#843732#8236. Snake MoveAksLolCodingWA 0ms3616kbC++171.2kb2025-01-05 00:10:212025-01-05 00:10:21

Judging History

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

  • [2025-01-05 00:10:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2025-01-05 00:10:21]
  • 提交

answer

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

const int dx[4]={0,0,1,-1}, dy[4]={-1,1,0,0};

void solve() {
    int n, m, k, hx, hy;
    cin >> n >> m >> k >> hx >> hy;
    int b[n][m];
    memset(b, 0, n*m*sizeof(int));
    b[--hx][--hy] = --k;
    while (k) {
        int x, y;
        cin >> x >> y;
        b[--x][--y] = --k;
    }
    char grid[n][m];
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> grid[i][j];

    // for (int ix = 0; ix < n; ix++) {
    // }

    // solve
    vector<array<int, 2>> v[n*m];
    int f[n][m]; // distance array
    memset(f, -1, n*m*sizeof(int));
    ll ans;
    v[f[hx][hy] = 0].push_back({hx, hy});
    for (int d = 0; d < n*m; d++) {
        for (auto &[x, y]: v[d]) {
            ans += (ll)d*d;
            for (int i: {0, 1, 2, 3}) {
                int nx = x+dx[i], ny = y+dy[i];
                if (nx < 0 || ny < 0 || nx>=n || ny>=m || grid[nx][ny] == '#' || ~f[nx][ny]) continue;
                v[f[nx][ny] = max(b[nx][ny],d)+1].push_back({nx, ny});
            }
        }
    }

    // ans
    cout << ans << '\n';
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    solve();
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3616kb

input:

4 5 5
3 5
3 4
3 3
3 2
4 2
.....
.....
.....
.....

output:

33061

result:

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