QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#636033#7034. HoneycombpskkkWA 81ms4380kbC++231.4kb2024-10-12 21:55:072024-10-12 21:55:07

Judging History

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

  • [2024-10-12 21:55:07]
  • 评测
  • 测评结果:WA
  • 用时:81ms
  • 内存:4380kb
  • [2024-10-12 21:55:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int dx[6] = {-1, 1, -1, 1, 2, -2};
const int dy[6] = {-3, 3, 3, -3, 0, 0};
void solve() {
    int n, m;
    cin >> n >> m;
    n = n * 4 + 3;
    m = m * 6 + 3;
    vector<string> a(n);
    getline(cin, a[0]);
    int sx, sy;
    for (int i = 0; i < n; ++i) {
        getline(cin, a[i]);
        for (int j = 0; j < m; j++)
            if (a[i][j] == 'S')
                sx = i, sy = j;
    }
    auto bfs = [&](auto self) -> int {
        queue<tuple<int, int, int>> Q;
        Q.push({sx, sy, 1});
        a[sx][sy] = '*';
        while (!Q.empty()) {
            int x, y, d;
            tie(x, y, d) = Q.front();
            Q.pop();
            for (int o = 0; o < 6; o++) {
                int cx = x + dx[o], nx = cx + dx[o];
                int cy = y + dy[o], ny = cy + dy[o];
                if (nx < 0 || ny < 0 || nx >= n || ny >= m || a[cx][cy] != ' ' || a[nx][ny] == '*')
                    continue;
                if (a[nx][ny] == 'T')
                    return d + 1;
                a[nx][ny] = '*';
                Q.push({nx, ny, d + 1});
            }
        }
        return -1;
    };
    cout << bfs(bfs) << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}

詳細信息

Test #1:

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

input:

1
3 4
  +---+       +---+
 /     \     /     \
+       +---+       +---+
 \           \     /     \
  +   +   S   +---+   T   +
 /     \     /           /
+       +---+       +   +
 \           \     /     \
  +---+       +---+       +
 /                       /
+       +---+       +   +
 \         ...

output:

7

result:

ok single line: '7'

Test #2:

score: -100
Wrong Answer
time: 81ms
memory: 4380kb

input:

400
67 89
  +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       +---+       ...

output:

91
132
8
71
57
51
83
151
400
67
9
3
196
597
33
212
49
29
527
20
23
51
280
22
40
91
541
33
488
125
13
357
263
220
47
182
293
254
11
82
97
39
176
15
65
13
65
75
32
9
60
77
152
14
69
110
45
555
191
173
109
207
7
225
232
97
108
326
118
79
78
414
222
44
31
58
47
228
32
48
15
133
521
350
242
85
201
48
105...

result:

wrong answer 398th lines differ - expected: '488', found: '-1'