#include <bits/stdc++.h>using namespace std; #define MAXN 105int 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;}
Blue Bridge Cup small simulation