QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#138932#4432. Jungle Trailckiseki#WA 77ms23188kbC++172.6kb2023-08-12 14:29:302023-08-12 14:29:33

Judging History

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

  • [2023-08-12 14:29:33]
  • 评测
  • 测评结果:WA
  • 用时:77ms
  • 内存:23188kb
  • [2023-08-12 14:29:30]
  • 提交

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) {
            if (x == '@' and y == 'N')
                return true;
            if (x == 'O' and y == 'T')
                return true;
            return false;
        };

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 77ms
memory: 23188kb

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
NNNTTTNTNN
NNTNTNTNTN
PPDDDPPDPDPPDDPDPD
TAK
NNNNTTTTTN
NNNTTNTTNN
PPDDPPPDPDPPDDPDDD
TAK
NTTTNNNTNT
NT...

result:

wrong answer you dead (test case 3)