#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
typedef long double ld;
const ll inf = 1e9;
const ld eps = 1e-8;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, m, q;
cin >> n >> m >> q;
vector<vector<char>> w(n, vector<char>(m));
for (ll i = 0; i < n; i++) {
for (ll j = 0; j < m; j++) {
cin >> w[i][j];
}
}
vector<bitset<502>> a(n), newa, bad(n);
for (ll i = 0; i < n; i++) {
for (ll j = 0; j < m; j++) {
if (w[i][j] == '.') {
a[i][j + 1] = 1;
} else {
bad[i][j + 1] = 1;
}
}
bad[i][0] = 1;
bad[i][m + 1] = 1;
}
for (ll qw = 0; qw < q; qw++) {
char t;
cin >> t;
if (t == 'E') {
for (ll i = 0; i < n; i++) {
a[i] <<= 1;
a[i] &= ~bad[i];
}
} else if (t == 'W') {
for (ll i = 0; i < n; i++) {
a[i] >>= 1;
a[i] &= ~bad[i];
}
} else if (t == 'N') {
for (ll i = 0; i < n - 1; i++) {
a[i] = a[i + 1];
a[i] &= ~bad[i];
}
a[n] = 0;
} else if (t == 'S') {
for (ll i = n - 1; i > 0; i--) {
a[i] = a[i - 1];
a[i] &= ~bad[i];
}
a[0] = 0;
} else {
newa = a;
for (ll i = 0; i < n; i++) {
newa[i] = (a[i] >> 1);
newa[i] |= (a[i] << 1);
if (i > 0) {
newa[i] |= a[i - 1];
}
if (i < n - 1) {
newa[i] |= a[i + 1];
}
newa[i] &= ~bad[i];
}
a = newa;
}
/*for(ll i = 0; i < n; i++) {
for(ll j = 1; j < m + 1; j++) {
cout << a[i][j];
}
cout << endl;
}
cout << endl << endl;*/
}
ll res = 0;
for (ll i = 0; i < n; i++) {
res += a[i].count();
}
cout << res << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |