#include<bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
constexpr int maxm = 5e3 + 1, maxa = 5e2 + 2;
bitset <maxa> ma[maxm][maxa];
vector<pii> dir[] = { vector<pii>{pii( -1, 0 )}, vector<pii>{pii( 1, 0 )}, vector<pii>{pii( 0, -1 )},
vector<pii>{pii( 0, 1 )}, vector<pii>{pii( -1, 0 ), pii(1, 0), pii(0, -1), pii(0, 1)}};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int r, c, m;
cin >> r >> c >> m;
string s;
for (int y = 1; y <= r; y++)
{
cin >> s;
for (int x = 1; x <= c; x++)
{
if (s[x - 1] == '.') ma[0][x][y] = true;
}
}
int output;
cin >> s;
int typ;
for (int i = 1; i <= m; i++)
{
if (s[i - 1]=='W') typ = 0;
else if (s[i - 1]=='E') typ = 1;
else if (s[i - 1]=='N') typ = 2;
else if (s[i - 1] == 'S') typ = 3;
else typ = 4;
// cout << dir[typ][0].first << " " << dir[typ][0].second << " " << dir[typ].size() <<"\n";
if (typ == 0 || typ == 4)
{
for (int x = 1; x < c; x++)
{
ma[i][x] |= (ma[0][x] & ma[i - 1][x + 1]);
}
}
if (typ == 1 || typ == 4)
{
for (int x = 2; x <= c; x++)
{
ma[i][x] |= (ma[0][x] & ma[i - 1][x - 1]);
}
}
if (typ == 2 || typ == 4)
{
for (int x = 1; x <= c; x++)
{
ma[i][x] |= (ma[0][x] & (ma[i - 1][x] >> 1));
}
}
if (typ == 3 || typ == 4)
{
for (int x = 1; x<= c; x++)
{
ma[i][x] |= (ma[0][x] & (ma[i - 1][x] << 1));
}
}
}
// for (int i = 0; i <= m; i++)
// {
// cout << i <<"\n";
// for (int y = 1; y <= r; y ++)
// {
// for (int x = 1; x <= c; x++) cout << ma[i][x][y];
// cout << "\n";
// }
// cout <<"\n";
// }
output = 0;
for (int x = 1; x <= c; x++)
{
output += ma[m][x].count();
}
cout << output << "\n";
//cerr << clock() / static_cast<double>(CLOCKS_PER_SEC) << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1236 KB |
Output is correct |
2 |
Correct |
1 ms |
1248 KB |
Output is correct |
3 |
Correct |
1 ms |
1236 KB |
Output is correct |
4 |
Correct |
1 ms |
1236 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1236 KB |
Output is correct |
2 |
Correct |
1 ms |
1248 KB |
Output is correct |
3 |
Correct |
1 ms |
1236 KB |
Output is correct |
4 |
Correct |
1 ms |
1236 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
2 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
2 ms |
1236 KB |
Output is correct |
14 |
Correct |
2 ms |
1236 KB |
Output is correct |
15 |
Correct |
1 ms |
1236 KB |
Output is correct |
16 |
Correct |
1 ms |
1236 KB |
Output is correct |
17 |
Correct |
1 ms |
1236 KB |
Output is correct |
18 |
Correct |
2 ms |
1364 KB |
Output is correct |
19 |
Correct |
2 ms |
1236 KB |
Output is correct |
20 |
Correct |
1 ms |
1236 KB |
Output is correct |
21 |
Correct |
2 ms |
1236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1236 KB |
Output is correct |
2 |
Correct |
1 ms |
1248 KB |
Output is correct |
3 |
Correct |
1 ms |
1236 KB |
Output is correct |
4 |
Correct |
1 ms |
1236 KB |
Output is correct |
5 |
Correct |
1 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
2 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
1236 KB |
Output is correct |
9 |
Correct |
1 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
2 ms |
1236 KB |
Output is correct |
14 |
Correct |
2 ms |
1236 KB |
Output is correct |
15 |
Correct |
1 ms |
1236 KB |
Output is correct |
16 |
Correct |
1 ms |
1236 KB |
Output is correct |
17 |
Correct |
1 ms |
1236 KB |
Output is correct |
18 |
Correct |
2 ms |
1364 KB |
Output is correct |
19 |
Correct |
2 ms |
1236 KB |
Output is correct |
20 |
Correct |
1 ms |
1236 KB |
Output is correct |
21 |
Correct |
2 ms |
1236 KB |
Output is correct |
22 |
Correct |
156 ms |
157428 KB |
Output is correct |
23 |
Correct |
156 ms |
157784 KB |
Output is correct |
24 |
Correct |
135 ms |
157712 KB |
Output is correct |
25 |
Correct |
137 ms |
157724 KB |
Output is correct |
26 |
Correct |
171 ms |
157692 KB |
Output is correct |
27 |
Correct |
191 ms |
157772 KB |
Output is correct |
28 |
Correct |
187 ms |
157784 KB |
Output is correct |
29 |
Correct |
185 ms |
157704 KB |
Output is correct |
30 |
Correct |
193 ms |
157676 KB |
Output is correct |
31 |
Correct |
189 ms |
157724 KB |
Output is correct |
32 |
Correct |
243 ms |
157684 KB |
Output is correct |
33 |
Correct |
231 ms |
157756 KB |
Output is correct |
34 |
Correct |
233 ms |
157756 KB |
Output is correct |
35 |
Correct |
229 ms |
157676 KB |
Output is correct |
36 |
Correct |
256 ms |
157644 KB |
Output is correct |