Submission #260142

# Submission time Handle Problem Language Result Execution time Memory
260142 2020-08-09T11:33:15 Z jdh Awesome Arrowland Adventure (eJOI19_adventure) C++17
38 / 100
1 ms 512 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<char,ll> mp = { {'N',0},{'E',1},{'S',2},{'W',3} };
vector<tuple<ll,ll,char>> dirs = { {-1,0,'N'},{0,1,'E'},{1,0,'S'},{0,-1,'W'} };
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,m;
  cin >> n >> m;
  vector<string> vs(n);
  for(ll i = 0; i < n; ++i) cin >> vs[i];
  vector<vector<ll>> val(n,vector<ll>(m,-1));
  set<tuple<ll,ll,ll>> sp;
  sp.emplace(0,0,0);
  while(!sp.empty()){
    ll a,x,y;
    tie(a,x,y) = *begin(sp);
    sp.erase(begin(sp));
    if(val[x][y] >= 0) continue;
    val[x][y] = a;
    if(x == n-1 and y == m-1) break;
    for(auto& dir : dirs){
      ll dx,dy;
      char d;
      tie(dx,dy,d) = dir;
      ll x1 = x+dx,y1 = y+dy;
      if(0 <= x1 and x1 < n and 0 <= y1 and y1 < m){
        if(val[x1][y1] == -1){
          if(vs[x1][y1] != 'X' or (x1 == n-1 and y1 == m-1)){
            ll delta = (mp[d]+4-mp[vs[x][y]])%4;
            sp.emplace(a+delta,x1,y1);
          }
        }
      }
    }
  }
  cout << val[n-1][m-1];
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Incorrect 1 ms 384 KB Output isn't correct