QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#138928 | #4432. Jungle Trail | ckiseki# | WA | 59ms | 23200kb | C++17 | 2.5kb | 2023-08-12 14:25:57 | 2023-08-12 14:25:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
template <typename ...T>
void debug_(const char *s, T ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int cnt = sizeof...(T);
(..., (cerr << a << (--cnt ? ", " : ")\e[0m\n")));
}
template <typename I>
void orange_(const char *s, I L, I R) {
cerr << "\e[1;32m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++L)
cerr << (f++ ? ", " : "") << *L;
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif
constexpr int kInf = 1 << 30;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
vector<string> a(n);
for (auto &ai : a)
cin >> ai;
auto d = vector(n, vector(m, kInf));
d[0][0] = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (i == 0 and j == 0)
continue;
if (a[i][j] == '#')
continue;
if (i) d[i][j] = min(d[i][j], d[i - 1][j] + 1);
if (j) d[i][j] = min(d[i][j], d[i][j - 1] + 1);
}
}
if (d[n - 1][m - 1] == kInf) {
cout << "NIE\n";
continue;
}
auto bad = [](char x, char y) {
return (x == '@') ^ (y == 'T');
};
string ans;
{
int x = n - 1, y = m - 1;
while (x != 0 or y != 0) {
if (x and d[x][y] == d[x - 1][y] + 1) {
ans += "D";
--x;
} else {
ans += "P";
--y;
}
}
}
reverse(ans.begin(), ans.end());
string hori(n, 'N'), vert(m, 'N');
int x = 0, y = 0;
for (auto c : ans) {
if (c == 'D') {
x++;
if (bad(a[x][y], vert[y])) {
hori[x] = 'T';
}
} else {
y++;
if (bad(a[x][y], hori[x])) {
vert[y] = 'T';
}
}
}
cout << "TAK\n";
cout << hori << '\n';
cout << vert << '\n';
cout << ans << '\n';
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 59ms
memory: 23200kb
input:
486 4 5 ..#.. @@O@@ ##@#O ..@.@ 2 2 OO OO 2 2 @@ @@ 2 2 @@ #@ 2 2 @O #@ 2 2 @@ OO 2 2 O# @O 2 2 @# #@ 2 2 @. .@ 2 2 @# .O 2 2 OO .O 10 10 @O@O#O@@@# OO#@#@@#OO #@#@#O##O@ OO##@@O#@O O##@@#@O#@ OO@OO@@@O@ @O#@#@O#@O @OOOOO@##. O@OOO##O@@ OO@@OOOO#@ 10 10 @@#OOO#O@@ #@@OO@@.O@ #.O@@O#@@O OO@@#O@#O@ .#...
output:
TAK NTNT NNTNN PDPPPDD TAK NN NN PD TAK NN NT PD TAK NN NT PD TAK NT NN PD TAK NT NT PD TAK NT NT DP NIE TAK NT NN PD TAK NN NN DP TAK NN NN PD NIE TAK NNTNNTTTTN NTTNNTTNNT PDPPPPPPPDDDDDPDDD TAK NNNTTTTNTT NNTNTNTTNT PPDDDPPDPDPPDDPDPD TAK NNNNTTTNNT NNNTTNTTNT PPDDPPPDPDPPDDPDDD TAK NTTTNNNTNT NT...
result:
wrong answer you dead (test case 3)