답안 #412458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
412458 2021-05-26T23:26:12 Z mbfibat Nautilus (BOI19_nautilus) C++17
100 / 100
289 ms 1096 KB
#pragma GCC target("popcnt")

#include <bits/stdc++.h>

using namespace std;

int R, C, M;
string s;

char c[501][501];
bitset<250000> org, cur, E, W;

int id(int i, int j) {
	return i * C + j;
}

int main(int argc, char** argv)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	 
	cin >> R >> C >> M;
	for (int i = 0; i < R; i++)
		for (int j = 0; j < C; j++) {
			cin >> c[i][j];

			int pos = id(i, j);
			if (c[i][j] == '.') {
				org.set(pos);
				cur.set(pos);
			}	
			if (j != C - 1) W.set(pos);
			if (j != 0) E.set(pos);
		}

	cin >> s;
	for (int i = 0; i < M; i++) {
		if (s[i] == 'N')
			cur = (cur >> C);	
		else if (s[i] == 'S') 	
			cur = (cur << C);
		else if (s[i] == 'W')
			cur = (cur >> 1) & W;
		else if (s[i] == 'E')
			cur = (cur << 1) & E;
		else
			cur = ((cur >> C) | (cur << C) | ((cur >> 1) & W) | ((cur << 1) & E));	
		cur &= org;
	}
	cout << cur.count();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 716 KB Output is correct
2 Correct 2 ms 716 KB Output is correct
3 Correct 3 ms 716 KB Output is correct
4 Correct 2 ms 716 KB Output is correct
5 Correct 3 ms 644 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 716 KB Output is correct
2 Correct 2 ms 716 KB Output is correct
3 Correct 3 ms 716 KB Output is correct
4 Correct 2 ms 716 KB Output is correct
5 Correct 3 ms 644 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 4 ms 716 KB Output is correct
8 Correct 4 ms 716 KB Output is correct
9 Correct 4 ms 716 KB Output is correct
10 Correct 4 ms 716 KB Output is correct
11 Correct 4 ms 716 KB Output is correct
12 Correct 6 ms 752 KB Output is correct
13 Correct 6 ms 716 KB Output is correct
14 Correct 5 ms 716 KB Output is correct
15 Correct 7 ms 716 KB Output is correct
16 Correct 6 ms 716 KB Output is correct
17 Correct 6 ms 716 KB Output is correct
18 Correct 9 ms 588 KB Output is correct
19 Correct 7 ms 716 KB Output is correct
20 Correct 6 ms 716 KB Output is correct
21 Correct 6 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 716 KB Output is correct
2 Correct 2 ms 716 KB Output is correct
3 Correct 3 ms 716 KB Output is correct
4 Correct 2 ms 716 KB Output is correct
5 Correct 3 ms 644 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 4 ms 716 KB Output is correct
8 Correct 4 ms 716 KB Output is correct
9 Correct 4 ms 716 KB Output is correct
10 Correct 4 ms 716 KB Output is correct
11 Correct 4 ms 716 KB Output is correct
12 Correct 6 ms 752 KB Output is correct
13 Correct 6 ms 716 KB Output is correct
14 Correct 5 ms 716 KB Output is correct
15 Correct 7 ms 716 KB Output is correct
16 Correct 6 ms 716 KB Output is correct
17 Correct 6 ms 716 KB Output is correct
18 Correct 9 ms 588 KB Output is correct
19 Correct 7 ms 716 KB Output is correct
20 Correct 6 ms 716 KB Output is correct
21 Correct 6 ms 716 KB Output is correct
22 Correct 142 ms 972 KB Output is correct
23 Correct 129 ms 1004 KB Output is correct
24 Correct 124 ms 1004 KB Output is correct
25 Correct 141 ms 1020 KB Output is correct
26 Correct 136 ms 1096 KB Output is correct
27 Correct 209 ms 1012 KB Output is correct
28 Correct 246 ms 1092 KB Output is correct
29 Correct 208 ms 1004 KB Output is correct
30 Correct 222 ms 1008 KB Output is correct
31 Correct 203 ms 988 KB Output is correct
32 Correct 268 ms 984 KB Output is correct
33 Correct 289 ms 980 KB Output is correct
34 Correct 274 ms 972 KB Output is correct
35 Correct 272 ms 988 KB Output is correct
36 Correct 273 ms 972 KB Output is correct