Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std; typedef long long ll; typedef unsigned long long ull; const int mod = 1e9 + 7, N = 1e5 + 1, inf = INT_MAX;
- #define fi first
- #define se second
- #define pb push_back
- #define mp make_pair
- #define ep emplace_back
- //#define int ll
- char a[111][111], go[111111];
- int o, u, v, n, m, s, x, y, ans;
- signed main()
- {
- ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- while (cin >> n >> m >> s && n + m + s)
- {
- for (int i = 1; i <= n; i++)
- {
- for (int j = 1; j <= m; j++)
- {
- cin >> a[i][j];
- if (a[i][j] == 'N' || a[i][j] == 'L' || a[i][j] == 'S' || a[i][j] == 'O')
- {
- if (a[i][j] == 'N') o = 0;
- if (a[i][j] == 'L') o = 1;
- if (a[i][j] == 'S') o = 2;
- if (a[i][j] == 'O') o = 3;
- u = i, v = j;
- }
- }
- }
- ans = 0;
- for (int i = 1; i <= s; i++)
- {
- cin >> go[i];
- }
- for (int i = 1; i <= s; i++)
- {
- if (go[i] == 'D')
- {
- o = (o + 1) % 4;
- }
- if (go[i] == 'E')
- {
- o = (o + 3) % 4;
- }
- if (go[i] == 'F')
- {
- x = u, y = v;
- if (o == 0) --x;
- if (o == 1) ++y;
- if (o == 2) ++x;
- if (o == 3) --y;
- if (!x || !y || x > n || y > m || a[x][y] == '#') continue; //back to start which is u, v
- a[u][v] = '.';
- if (a[x][y] == '*') ans++;
- u = x, v = y;
- }
- }
- cout << ans << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement