#include <bits/stdc++.h>
using namespace std;
#define maxn 105
int m, n, x, y, k;
char s;
int a[maxn][maxn];
int cnt;
void solve()
{
while(cnt++ < k)
{
if(s == 'U')
{
if(a[x][y])
{
a[x][y++] = 0;
s = 'R';
}
else
{
a[x][y--] = 1;
s = 'L';
}
//cout<<x<<" "<<y<<" "<<s<<endl;
continue;
}
if(s == 'D')
{
if(a[x][y])
{
a[x][y--] = 0;
s = 'L';
}
else
{
a[x][y++] = 1;
s = 'R';
}
//cout<<x<<" "<<y<<" "<<s<<endl;
continue;
}
if(s == 'L')
{
if(a[x][y])
{
a[x--][y] = 0;
s = 'U';
}
else
{
a[x++][y] = 1;
s = 'D';
}
//cout<<x<<" "<<y<<" "<<s<<endl;
continue;
}
if(s == 'R')
{
if(a[x][y])
{
a[x++][y] = 0;
s = 'D';
}
else
{
a[x--][y] = 1;
s = 'U';
}
//cout<<x<<" "<<y<<" "<<s<<endl;
continue;
}
}
// cout<<cnt<<endl;
}
int main()
{
while(~scanf("%d%d", &m, &n))
{
cnt = 0;
for(int i=0; i<m; i++)
for(int j=0; j<n; j++)
scanf("%d", &a[i][j]);
scanf("%d%d", &x, &y);
getchar();
cin>>s>>k;
solve();
cout<<x<<" "<<y<<endl;
}
return 0;
}
蓝桥杯 小模拟
最新推荐文章于 2020-10-10 14:51:56 发布