#include <bits/stdc++.h>
using namespace std;
#define REP(i, l, r) for(int i = (l); i < (r); ++i)
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define FORD(i, r, l) for(int i = (r); i >= (l); --i)
#define ff first
#define ss second
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(v) (int)v.size()
#define compact(v) v.erase(unique(all(v)), v.end())
#define dbg(v) "[" #v " = " << (v) << "]"
#define el "\n"
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
template<class T> bool minimize(T& a, const T& b){ if(a > b) return a = b, true; return false; }
template<class T> bool maximize(T& a, const T& b){ if(a < b) return a = b, true; return false; }
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
long long randRange(long long l, long long r){ return uniform_int_distribution<long long>(l,r)(rng); }
const int N = 10;
int n, m, k;
bitset<N> a[2][N], b[N];
string s;
void solve() {
cin >> n >> m >> k;
FOR(i, 1, n) {
FOR(j, 1, m) {
char c; cin >> c;
a[0][i][j] = (c == '.' ? 1 : 0);
}
b[i] = a[0][i];
}
// FOR(i, 1, n) cout << a[0][i] << el;
// cout << el;
string op; cin >> op;
for (auto t : op) {
if (t == 'N') {
FOR(i, 1, n) a[1][i] = a[0][i + 1] & b[i];
}
else if (t == 'S') {
FOR(i, 1, n) a[1][i] = a[0][i - 1] & b[i];
}
else if (t == 'E') {
FOR(i, 1, n) a[1][i] = (a[0][i] << 1) & b[i];
}
else if (t == 'W') {
FOR(i, 1, n) a[1][i] = (a[0][i] >> 1) & b[i];
}
else {
FOR(i, 1, n) a[1][i] = (a[0][i + 1] | a[0][i - 1] | (a[0][i] >> 1) | (a[0][i] << 1)) & b[i];
}
FOR(i, 1, n) a[0][i] = a[1][i];
// cout << el;
// FOR(i, 1, n) cout << a[0][i] << el;
// cout << el;
}
ll ans = 0;
FOR(i, 1, n) ans += a[0][i].count();
cout << ans << el;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
#define task "task"
if(fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
solve();
return 0;
}
/*
*/
컴파일 시 표준 에러 (stderr) 메시지
nautilus.cpp: In function 'int main()':
nautilus.cpp:87:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
87 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:88:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
88 | freopen(task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |