Submission #56011685


Source Code Expand

/*
Author: rnishiura
Date: 24-07-20
Description: template
*/

#define ATCODER_
#include <bits/stdc++.h>
#ifdef ATCODER_
#include <atcoder/all>
#endif
#define _GLIBCXX_DEBUG
#define rep(x, n)      for(ll x=0; x<n; x++)
#define repi(x, a, b)  for(ll x=a; x<b; x++)
#define rrep(x, n)     for(ll x=n-1; x>=0; x--)
#define rrepi(x, a, b) for(ll x=b-1; x>=a; x--)
#define SQ(z) ((z)*(z))
#define contains(x, a) ((a).find(x) != (a).end())
#define all(a) (a).begin(), (a).end()
#define sum(a)  (accumulate(all(a), 0LL))
#define mini(a) (min_element(all(a)) - (a).begin())
#define maxi(a) (max_element(all(a)) - (a).begin())
#define mine(a) (*min_element(all(a)))
#define maxe(a) (*max_element(all(a)))
#define lowb(x, a) (lower_bound(all(a), (x)) - (a).begin())
#define uppb(x, a) (upper_bound(all(a), (x)) - (a).begin())
#define divl(n, m)  ((n+m)/(m)) 
#define divle(n, m) ((n+m-1)/(m)) 
#define divse(n, m) ((n)/(m)) 
#define divs(n, m)  ((n-1)/(m)) 
#define bstoi(s)  stoi((s), nullptr, 2)
#define MOD 998244353
#define PI 3.14159265358979323846
#define inf (1LL << 61)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define POS  fi
#define COST se
#define endl '\n'
#define unordered_multiset multiset

#define VNAME(v) #v
#define GET_MACRO(_1,_2,_3, NAME,...) NAME
#define print(...) GET_MACRO(__VA_ARGS__, print3, print2, print1)(__VA_ARGS__)
#define debug(...) GET_MACRO(__VA_ARGS__, debug3, debug2, debug1)(__VA_ARGS__)

#define print1(z)       { cout << (z) << endl;              }
#define print2(y, z)    { cout << (y) << ' '; print1(z);     }
#define print3(x, y, z) { cout << (x) << ' '; print2(y, z); }
#define debug1(z)       { if(DEBUG) { print(VNAME(z)); print(z); } }
#define debug2(y, z)    { if(DEBUG) { print(VNAME(y), VNAME(z)); print(y, z); }    }
#define debug3(x, y, z) { if(DEBUG) { print(VNAME(x), VNAME(y), VNAME(z)); print(x, y, z); } }
#ifdef ATCODER_
using namespace atcoder;
using mint = modint998244353;
#endif

using namespace std;
using ll  = long long;
using v   = vector<ll>;
using vv  = vector<v>;
using vp  = vector<pair<ll, ll>>;
using vvp = vector<vp>;

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U> &p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>  p){os << p.first << ' ' << p.second; return os;}
template<typename T>             vector<T>& operator--            (vector<T> &v){for (auto& i : v) --i;            return  v;}
template<typename T>             vector<T>& operator++            (vector<T> &v){for (auto& i : v) ++i;            return  v;}
template<typename T>             istream& operator>>(istream& is,  vector<T> &v){for (auto& i : v) is >> i;        return is;}
// template<typename T>             ostream& operator<<(ostream& os,  vector<bool>  v){for (auto i : v) os << (i ? 'T' : 'F') << ' '; return os;}
template<typename T>             ostream& operator<<(ostream& os,  vector<T>  v){for (auto i : v) os << i << ' '; return os;}
template<typename T>             ostream& operator<<(ostream& os,  vector<vector<T>>  v){for (auto& i : v) os << i << endl; return os;}
template<typename T, typename U> pair<T,U>& operator--           (pair<T, U> &p){--p.first; --p.second;            return  p;}
template<typename T, typename U> pair<T,U>& operator++           (pair<T, U> &p){++p.first; ++p.second;            return  p;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> pair<T,T> operator*(pair<T,T> a,         U b){return mp(a.first*b      , a.second*b);}
template<typename T, typename U> pair<T,T> operator/(pair<T,T> a,         U b){return mp(a.first/b      , a.second/b);}
template<typename T, typename U> pair<T,T> operator%(pair<T,T> a,         U b){return mp(a.first%b      , a.second%b);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}


const string DEBUG_MESSAGE = "DEBUG MODE IS ON";
// const int DEBUG = 1;
const int DEBUG = 0;

void build_walls(vector<string> &s) {
  ll w = s[0].length();
  string t(w+2, '#');
  for(auto& ss: s) ss = "#" + ss + "#";
  s.insert(s.begin(), t);
  s.pb(t);
}

void solve() {
  ll h, w, sx, sy; cin >> h >> w >> sy >> sx;

  vector<string> c(h); cin >> c;
  build_walls(c);

  string x; cin >> x;

  for(auto d: x) {
    switch(d) {
      case 'U':
      if(c[sy-1][sx] =='.') {sy--;}
      break;
      case 'R':
      if(c[sy][sx+1] =='.') {sx++;}
      break;
      case 'D':
      if(c[sy+1][sx] =='.') {sy++;}
      break;
      case 'L':
      if(c[sy][sx-1] =='.') {sx--;}
      break;
    }
  }

  print2(sy, sx);
}

int main(void) {
  debug(DEBUG_MESSAGE);

  cin.tie(nullptr); ios::sync_with_stdio(false);
  
  ll t = 1; // cin >> t;
  rep(i, t) solve();

  debug(DEBUG_MESSAGE);
}

Submission Info

Submission Time
Task B - Grid Walk
User rnishiura
Language C++ 23 (gcc 12.2)
Score 200
Code Size 5202 Byte
Status AC
Exec Time 1 ms
Memory 3680 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 21
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt
Case Name Status Exec Time Memory
sample00.txt AC 1 ms 3520 KiB
sample01.txt AC 1 ms 3584 KiB
sample02.txt AC 1 ms 3528 KiB
testcase00.txt AC 1 ms 3448 KiB
testcase01.txt AC 1 ms 3452 KiB
testcase02.txt AC 1 ms 3544 KiB
testcase03.txt AC 1 ms 3668 KiB
testcase04.txt AC 1 ms 3512 KiB
testcase05.txt AC 1 ms 3460 KiB
testcase06.txt AC 1 ms 3476 KiB
testcase07.txt AC 1 ms 3668 KiB
testcase08.txt AC 1 ms 3548 KiB
testcase09.txt AC 1 ms 3524 KiB
testcase10.txt AC 1 ms 3536 KiB
testcase11.txt AC 1 ms 3396 KiB
testcase12.txt AC 1 ms 3680 KiB
testcase13.txt AC 1 ms 3536 KiB
testcase14.txt AC 1 ms 3600 KiB
testcase15.txt AC 1 ms 3528 KiB
testcase16.txt AC 1 ms 3468 KiB
testcase17.txt AC 1 ms 3676 KiB