| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 522212 | blue | Nautilus (BOI19_nautilus) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bitset>
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';
}
