답안 #1025593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1025593 2024-07-17T07:56:04 Z vjudge1 Awesome Arrowland Adventure (eJOI19_adventure) C++17
100 / 100
122 ms 15548 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    char pat[n][m];
    for (int i=0;i<n;i++)
        for (int j=0;j<m;j++)
            cin >> pat[i][j];
    priority_queue<pair<int, pair<int,int> > > pq;
    pq.push({0, {0, 0}});
    int vis[n][m];
    memset(vis, -1, sizeof(vis));
    while (!pq.empty()) {
        int r=pq.top().second.first, c=pq.top().second.second, dist=-pq.top().first;
        pq.pop();
        if (r>=n||c>=m||r<0||c<0) continue;
        if (vis[r][c]!=-1) continue;
        vis[r][c]=dist;
        if (pat[r][c]=='X') continue;
        if (pat[r][c]=='E') {
            pq.push({-dist, {r, c+1}});
            pq.push({-(dist+1), {r+1, c}});
            pq.push({-(dist+2), {r, c-1}});
            pq.push({-(dist+3), {r-1, c}});
        }
        else if (pat[r][c]=='N') {
            pq.push({-dist, {r-1, c}});
            pq.push({-(dist+1), {r, c+1}});
            pq.push({-(dist+2), {r+1, c}});
            pq.push({-(dist+3), {r, c-1}});
        }
        else if (pat[r][c]=='W') {
            pq.push({-dist, {r, c-1}});
            pq.push({-(dist+1), {r-1, c}});
            pq.push({-(dist+2), {r, c+1}});
            pq.push({-(dist+3), {r+1, c}});
        }
        else {
            pq.push({-dist, {r+1, c}});
            pq.push({-(dist+1), {r, c-1}});
            pq.push({-(dist+2), {r-1, c}});
            pq.push({-(dist+3), {r, c+1}});
        }
    }
    cout << vis[n-1][m-1];

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 600 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 8 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 10 ms 348 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 97 ms 1784 KB Output is correct
40 Correct 95 ms 1624 KB Output is correct
41 Correct 8 ms 1624 KB Output is correct
42 Correct 96 ms 1628 KB Output is correct
43 Correct 122 ms 15548 KB Output is correct
44 Correct 8 ms 1624 KB Output is correct