// _| _|
// _| _| _| _| _|_| _|_|_| _|_|_| _| _| _|_| _|_|
// _|_| _| _| _|_|_|_| _| _| _|_| _|_| _|_|_|_| _|_|_|_|
// _| _| _| _| _| _| _| _|_| _| _| _| _|
// _| _| _|_|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|
// _| _|
// _|_| _|
#include <iostream>
#include <bitset>
#include <vector>
using namespace std;
// #define DEBUG
#ifdef DEBUG
#define dassert(x) assert(x);
#define df(...) printf(__VA_ARGS__)
#else
#define dassert(x)
#define df(...)
#endif
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define ir(x, a, b) ((a) <= (x) && (x) <= (b))
#define vec vector
#define sz(x) (ll)x.size()
#define foru(i, n) for (int i = 0; (i) < (n); ++(i))
#define all(x) (x).begin(), (x).end()
typedef int64_t ll;
int read() {
int n = 0; bool b = 0; char c = getchar();
for (; !ir(c, '0', '9'); c = getchar()) b = (c == '-');
for (; ir(c, '0', '9'); c = getchar()) n = 10*n + (c-'0');
if (b) return -n;
return n;
}
const int N = 502;
// const int N = 20;
int n, m, k;
struct area {
vec<bitset<N>> v;
area() {
v.resize(n+2);
}
void operator &=(const area& other) {
foru (i, n+2) {
v[i] &= other.v[i];
}
}
void operator |=(const area& other) {
foru (i, n+2) {
v[i] |= other.v[i];
}
}
int count() {
int s = 0;
for (auto& b : v) {
s += m+2 - b.count();
}
return s;
}
};
area movey(const area& src, int by) {
area a;
for (int i = 1; i <= n; ++i) {
a.v[i] = src.v[i+by];
}
return a;
}
area movex(area a, int by) {
for (int i = 1; i <= n; ++i) {
if (by < 0) {
a.v[i] <<= -by;
} else {
a.v[i] >>= by;
}
}
// for (int i = 0; i <= n+1; ++i) {
// cout << a.v[i] << "\n";
// }
// cout << "\n";
return a;
}
int main() {
df("debug mode\n");
#ifndef DEBUG
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
cin >> n >> m >> k;
area a;
for (int i = 1; i <= n; ++i) {
string s;
cin >> s;
for (int j = 1; j <= m; ++j) {
a.v[i][j] = (s[j-1] == '#');
}
}
string s;
cin >> s;
foru (i, m+2) {
a.v[0][i] = a.v[n+1][i] = 1;
}
foru (i, n+2) {
a.v[i][0] = a.v[i][m+1] = 1;
}
// area b = a;
foru (i, k) {
char c = s[i];
if (c == 'N') {
a |= movey(a, -1);
} else if (c == 'S') {
a |= movey(a, 1);
} else if (c == 'E') {
a |= movex(a, -1);
} else if (c == 'W') {
a |= movex(a, 1);
}
// for (int i = 0; i <= n+1; ++i) {
// cout << a.v[i] << "\n";
// }
// cout << "\n";
}
cout << a.count() << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |