| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 946497 | promitheas | Nautilus (BOI19_nautilus) | C++14 | 216 ms | 1084 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//BOI 2019 NAUTILUS
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <bitset>
#define MAXR 550
#define MAXC 550
#define MAXM 5500
using namespace std;
int R, C, M;
char RAWDAT[MAXR][MAXC];
bitset < MAXC > SEA[MAXR];
bitset < MAXC > CUR[MAXR];
bitset < MAXC > NCUR[MAXR];
bitset < MAXC > BCUR[MAXR];
void cpy_bl(bitset<MAXC>* d, bitset<MAXC>* s, int c) {
for (int i = 0; i < c; ++i)
d[i] = s[i];
}
void or_bl(bitset<MAXC>* d, bitset<MAXC>* s, int c) {
for (int i = 0; i < c; ++i)
d[i] |= s[i];
}
void west() {
for (int r = 0; r < R; ++r)
NCUR[r] = (CUR[r] << 1) & SEA[r];
}
void east() {
for (int r = 0; r < R; ++r) {
NCUR[r] = (CUR[r] >> 1) & SEA[r];
NCUR[r].reset(C);
}
}
void north() {
for (int r = 1; r < R; ++r)
NCUR[r - 1] = CUR[r] & SEA[r - 1];
NCUR[R - 1].reset();
}
void south() {
for (int r = 0; r < R - 1; ++r) {
NCUR[r + 1] = CUR[r] & SEA[r + 1];
}
NCUR[0].reset();
}
void anymove() {
for (int r = 0; r < R; ++r)
BCUR[r].reset();
north();
or_bl(BCUR, NCUR, R);
south();
or_bl(BCUR, NCUR, R);
east();
or_bl(BCUR, NCUR, R);
west();
or_bl(NCUR, BCUR, R);
}
void move(char c) {
switch (c) {
case 'N':
north();
break;
case 'W':
west();
break;
case 'S':
south();
break;
case 'E':
east();
break;
case '?':
anymove();
break;
}
for (int r = 0; r < R; ++r)
CUR[r] = NCUR[r];
}
char Q[MAXM];
int main() {
(void)scanf("%d%d%d", &R, &C, &M);
for (int r = 0; r < R; ++r) {
(void)scanf(" %s", RAWDAT[r]);
for (int c = 0; c < C; ++c) {
SEA[r].set(C-c-1, RAWDAT[r][c] == '.');
}
}
for (int r = 0; r < R; ++r)
CUR[r] = SEA[r];
scanf(" %s", Q);
#ifdef DEBUG
for (int i = 0; i < R; ++i) {
printf("%9s\n", CUR[i].to_string().c_str());
}
#endif
for (int i = 0; i < M; ++i) {
move(Q[i]);
#ifdef DEBUG
printf("\n\n");
for (int i = 0; i < R; ++i) {
printf("%9s\n", CUR[i].to_string().c_str());
}
#endif
}
int c = 0;
for (int i = 0; i < R; ++i) {
c += CUR[i].count();
}
printf("%d\n", c);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
