Submission #446761

# Submission time Handle Problem Language Result Execution time Memory
446761 2021-07-23T08:18:29 Z fuad27 Awesome Arrowland Adventure (eJOI19_adventure) C++14
22 / 100
8 ms 4392 KB
#include<bits/stdc++.h>

using namespace std;
#define int long long
#define MAX 507
vector < vector < int >> g(MAX, vector < int > (MAX, 0));
vector < vector < int >> dist(MAX, vector < int > (MAX, -1));
int dx[4] = {
    0,
    1,
    0 - 1
}, dy[4] = {
    -1,
    0,
    1,
    0
}, n, m;
void dj() {
    priority_queue < pair < int, pair < int, int >> , vector < pair < int, pair < int, int >> > , greater < pair < int, pair < int, int > > > > pq;
    pq.push(make_pair(0, make_pair(0, 0)));
    while (!pq.empty()) {
        int x = pq.top().second.first, y = pq.top().second.second, c = pq.top().first;
        pq.pop();
        if (x < 0 || x >= m || y < 0 || y >= n || dist[y][x] != -1) continue;
        dist[y][x] = c;
        if (g[y][x] == -1) continue;
        for (int i = 0; i < 4; i++) pq.push(make_pair(c + i, make_pair(x + dx[(g[y][x] + i) % 4], y + dy[(g[y][x] + i) % 4])));
    }
}
int32_t main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            char c;
            cin >> c;
            if (c == 'N') g[i][j] = 0;
            if (c == 'E') g[i][j] = 1;
            if (c == 'S') g[i][j] = 2;
            if (c == 'W') g[i][j] = 3;
            else if (c == 'X') g[i][j] = -1;
        }
    }
    dj();
    cout << dist[n - 1][m - 1] << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4300 KB Output is correct
2 Correct 3 ms 4300 KB Output is correct
3 Correct 3 ms 4300 KB Output is correct
4 Correct 3 ms 4300 KB Output is correct
5 Correct 3 ms 4300 KB Output is correct
6 Correct 3 ms 4392 KB Output is correct
7 Correct 3 ms 4300 KB Output is correct
8 Correct 3 ms 4300 KB Output is correct
9 Correct 3 ms 4300 KB Output is correct
10 Correct 3 ms 4300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4300 KB Output is correct
2 Correct 3 ms 4300 KB Output is correct
3 Correct 3 ms 4300 KB Output is correct
4 Correct 3 ms 4300 KB Output is correct
5 Correct 3 ms 4300 KB Output is correct
6 Correct 3 ms 4392 KB Output is correct
7 Correct 3 ms 4300 KB Output is correct
8 Correct 3 ms 4300 KB Output is correct
9 Correct 3 ms 4300 KB Output is correct
10 Correct 3 ms 4300 KB Output is correct
11 Correct 3 ms 4300 KB Output is correct
12 Correct 4 ms 4300 KB Output is correct
13 Correct 3 ms 4300 KB Output is correct
14 Correct 3 ms 4300 KB Output is correct
15 Correct 3 ms 4300 KB Output is correct
16 Correct 8 ms 4300 KB Output is correct
17 Correct 3 ms 4300 KB Output is correct
18 Correct 4 ms 4300 KB Output is correct
19 Correct 4 ms 4300 KB Output is correct
20 Correct 3 ms 4300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4236 KB Output is correct
2 Incorrect 3 ms 4300 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4300 KB Output is correct
2 Correct 3 ms 4300 KB Output is correct
3 Correct 3 ms 4300 KB Output is correct
4 Correct 3 ms 4300 KB Output is correct
5 Correct 3 ms 4300 KB Output is correct
6 Correct 3 ms 4392 KB Output is correct
7 Correct 3 ms 4300 KB Output is correct
8 Correct 3 ms 4300 KB Output is correct
9 Correct 3 ms 4300 KB Output is correct
10 Correct 3 ms 4300 KB Output is correct
11 Correct 3 ms 4300 KB Output is correct
12 Correct 4 ms 4300 KB Output is correct
13 Correct 3 ms 4300 KB Output is correct
14 Correct 3 ms 4300 KB Output is correct
15 Correct 3 ms 4300 KB Output is correct
16 Correct 8 ms 4300 KB Output is correct
17 Correct 3 ms 4300 KB Output is correct
18 Correct 4 ms 4300 KB Output is correct
19 Correct 4 ms 4300 KB Output is correct
20 Correct 3 ms 4300 KB Output is correct
21 Incorrect 3 ms 4300 KB Output isn't correct
22 Halted 0 ms 0 KB -