Submission #56006837
Source Code Expand
#include <cstdio>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <cctype>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cmath>
namespace uvu
{
#define LOCAL ________________DONT_DEFINE_ME_______________
#define ll long long
#define inf 0x3f3f3f3f
// #define int long long
// #define inf 0x3f3f3f3f3f3f3f3fll
#define infll 0x3f3f3f3f3f3f3f3fll
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define gline debug("now is #%d\n", __LINE__)
#define pii std::pair <int, int>
#define mkp std::make_pair
#define fi first
#define se second
char _ST_;
const int BUFSIZE = (1 << 20);
char ibuf[BUFSIZE], *iS = ibuf, *iT = ibuf;
char obuf[BUFSIZE], *oS = obuf, *oT = obuf + BUFSIZE;
char getc()
{
#ifdef LOCAL
return getchar();
#else
if(iS == iT) iT = (iS = ibuf) + fread(ibuf, 1, BUFSIZE, stdin);
return (iS == iT) ? EOF : *iS++;
#endif
#define getchar ERR
}
void Flush() { fwrite(obuf, 1, oS - obuf, stdout); oS = obuf; }
struct Flusher { ~Flusher() { Flush(); } }iamflusher;
void putc(char c)
{
#ifdef LOCAL
putchar(c);
#else
*oS++ = c;
if(oS == oT) Flush();
#endif
}
template <typename T = int> T read()
{
T x = 0, f = 1; char c = getc();
for(; !isdigit(c); c = getc()) if(c == '-') f = -1;
for(; isdigit(c); c = getc()) x = (x << 3) + (x << 1) + (c ^ 48);
return x * f;
}
template <typename T> void print(T x, char c)
{
static int sta[BUFSIZE], top;
top = 0;
if(x < 0) putc('-'), x *= -1;
if(!x) sta[++top] = 0;
for(; x; x /= 10) sta[++top] = x % 10;
for(; top; putc(sta[top--] ^ 48));
if(c) putc(c);
}
int readstr(char *s, int base)
{
int idx = base - 1; char c = getc();
for(; !(isdigit(c) || isalpha(c) || c == '#' || c == '.'); c = getc());
for(; isdigit(c) || isalpha(c) || c == '#' || c == '.' ; c = getc()) s[++idx] = c;
return idx - base + 1;
}
void printf(const char *s) { for(; *s; s++) putc(*s); }
template <typename T, typename ... Args >
void printf(const char *s, T x, Args ... rest)
{
for(; *s; s++)
{
if(*s != '%') { putc(*s); continue; }
s++; if(*s == 'd') print(x, 0);
else if(*s == 'c') putc(x);
printf(s + 1, rest ...);
return;
}
}
template <typename T> void ckmin(T &x, T y) { x = x < y ? x : y; }
template <typename T> void ckmax(T &x, T y) { x = x > y ? x : y; }
#define mod 998244353
// #define mod 1000000007
int sm(int x) { return x >= mod ? x - mod : x; }
void plus_(int &x, int y) { x = sm(x + y); }
void mul_(int &x, int y) { x = 1ll * x * y % mod; }
int ksm(int a, int b) { int res = 1; for(; b; b >>= 1, mul_(a, a)) if(b & 1) mul_(res, a); return res; }
#define N 5010
int n, m, x, y;
char mp[N][N];
char s[1000010];
void solve()
{
// memset(h, idx = -1, sizeof(h));
n = read(), m = read();
x = read(), y = read();
for(int i = 1; i <= n; i++) readstr(mp[i], 1);
int p = readstr(s, 1);
for(int i = 1; i <= p; i++)
{
if(s[i] == 'U' && x != 1 && mp[x - 1][y] != '#') x--;
if(s[i] == 'D' && x != n && mp[x + 1][y] != '#') x++;
if(s[i] == 'L' && y != 1 && mp[x][y - 1] != '#') y--;
if(s[i] == 'R' && y != m && mp[x][y + 1] != '#') y++;
}
printf("%d %d\n", x, y);
}
void init()
{
}
char _ED_;
void mian()
{
debug("%.3f MB\n", abs(&_ST_ - &_ED_) / 1024.0 / 1024);
init();
int T = 1;
for(; T; solve(), T--);
}
#ifdef int
#undef int
#endif
}
int main()
{
// freopen("tmp.in", "r", stdin);
// freopen("tmp.out", "w", stdout);
uvu::mian(); return 0;
}
Submission Info
| Submission Time |
|
| Task |
B - Grid Walk |
| User |
ningago |
| Language |
C++ 20 (gcc 12.2) |
| Score |
200 |
| Code Size |
3524 Byte |
| Status |
AC |
| Exec Time |
1 ms |
| Memory |
3452 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
200 / 200 |
| Status |
|
|
| 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 |
3112 KiB |
| sample01.txt |
AC |
1 ms |
3208 KiB |
| sample02.txt |
AC |
1 ms |
3176 KiB |
| testcase00.txt |
AC |
1 ms |
3204 KiB |
| testcase01.txt |
AC |
1 ms |
3216 KiB |
| testcase02.txt |
AC |
1 ms |
3396 KiB |
| testcase03.txt |
AC |
1 ms |
3424 KiB |
| testcase04.txt |
AC |
1 ms |
3400 KiB |
| testcase05.txt |
AC |
1 ms |
3452 KiB |
| testcase06.txt |
AC |
1 ms |
3372 KiB |
| testcase07.txt |
AC |
1 ms |
3404 KiB |
| testcase08.txt |
AC |
1 ms |
3296 KiB |
| testcase09.txt |
AC |
1 ms |
3444 KiB |
| testcase10.txt |
AC |
1 ms |
3396 KiB |
| testcase11.txt |
AC |
1 ms |
3312 KiB |
| testcase12.txt |
AC |
1 ms |
3340 KiB |
| testcase13.txt |
AC |
1 ms |
3404 KiB |
| testcase14.txt |
AC |
1 ms |
3240 KiB |
| testcase15.txt |
AC |
1 ms |
3404 KiB |
| testcase16.txt |
AC |
1 ms |
3424 KiB |
| testcase17.txt |
AC |
1 ms |
3412 KiB |