답안 #730373

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
730373 2023-04-25T18:30:25 Z aykhn Awesome Arrowland Adventure (eJOI19_adventure) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>

/*
    author: aykhn
    4/24/2023
*/

using namespace std;

typedef long long ll;

#define OPT ios_base::sync_with_stdio(0); \
            cin.tie(0); \
            cout.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()
#define mpr make_pair
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define inf 0x3F3F3F3F
#define infll 0x3F3F3F3F3F3F3F3FLL
#define bpc __builtin_popcount
#define print(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout<<endl;


int main()
{
    OPT;
    int n, m;
    cin >> n >> m;

    vector<vector<char>> v(n, vector<char> (m));
    vector<vector<int>> dist(n, vector<int> (m, inf));

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> v[i][j];
            if (v[i][j] == 'X') dist[i][j] = -inf;
        }
    }

    dist[n - 1][m - 1] = inf;

    priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> pq;

    dist[0][0] = 0;
    pq.push(mpr(0, mpr(0, 0)));

    int a[4] = {-1, 0, 0, 1};
    int b[4] = {0, -1, 1, 0};
    vector<vector<int>> ways(26, vector<int> (26, 0));

    ways[4][18] = 1;
    ways[4][22] = 2;
    ways[4][13] = 3;
    ways[13][4] = 1;
    ways[13][18] = 2;
    ways[13][22] = 3;
    ways[18][22] = 1;
    ways[18][13] = 2;
    ways[18][4] = 3;
    ways[22][13] = 1;
    ways[22][4] = 2;
    ways[22][18] = 3;

    while (!pq.empty())
    {
        int x = pq.top().se.fi;
        int y = pq.top().se.se;
        int w = pq.top().fi;
        pq.pop();

        for (int i = 0; i < 4; i++)
        {
            int x1 = x + a[i];
            int y1 = y + b[i];

            if (x1 >= n || x1 < 0 || y1 >= m || y1 < 0) continue;
            char ch;
            if (a[i] == -1 && b[i] == 0) ch = 'N';
            else if (a[i] == 1 && b[i] == 0) ch = 'S';
            else if (a[i] == 0 && b[i] == -1) ch = 'W';
            else ch = 'E';
            int d = ways[v[x][y] - 'A'][ch - 'A'];
            if (d + w < dist[x1][y1])
            {
                dist[x1][y1] = d + w;
                pq.push(mpr(dist[x1][y1], mpr(x1, y1)));
            }
        }
    }

    cout << dist[n - 1][m - 1] << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -