#include <iostream>
#include <bitset>
#include <algorithm>
using namespace std;
const int mx = 10;
int main()
{
bitset<(mx+2) * (mx+2)> grid, DP0, DP1;
grid.reset();
int R, C, M;
cin >> R >> C >> M;
for(int i = 1; i <= R; i++)
{
for(int j = 1; j <= C; j++)
{
char c;
cin >> c;
if(c == '.')
grid.set((mx+2) * i + j);
}
}
// cerr << "\n";
// for(int i = 0; i < (mx+2)*(mx+2); i++)
// {
// cerr << grid[i] << ' ';
// if(i % (mx+2) == mx+1) cerr << '\n';
// }
string S;
cin >> S;
reverse(S.begin(), S.end());
DP0 = grid;
for(char c : S)
{
// cerr << "\n\n\n c = " << c << '\n';
DP1 = DP0;
// for(int i = 0; i < (mx+2)*(mx+2); i++)
// {
// cerr << DP1[i] << ' ';
// if(i % (mx+2) == mx+1) cerr << '\n';
// }
// cerr << "-----\n";
if(c == 'N') DP1 >>= (mx+2);
else if(c == 'S') DP1 <<= (mx+2);
else if(c == 'W') DP1 >>= 1;
else if(c == 'E') DP1 <<= 1;
DP1 &= grid;
// for(int i = 0; i < (mx+2)*(mx+2); i++)
// {
// cerr << DP1[i] << ' ';
// if(i % (mx+2) == mx+1) cerr << '\n';
// }
swap(DP0, DP1);
}
cout << DP0.count() << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
552 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
552 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
552 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |