제출 #159688

#제출 시각아이디문제언어결과실행 시간메모리
159688DrSwadNautilus (BOI19_nautilus)C++17
100 / 100
221 ms760 KiB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#endif

typedef long long ll;
typedef unsigned int uint;

typedef pair<int, int> pii;
#define x first
#define y second

#define size(a) (int)a.size()

const int N = 505, M = 5005;

int rows, cols, tot_moves;
bitset<N> grid[N];
bitset<N> vis[2][N];
char moves[M];

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	scanf("%d %d %d", &rows, &cols, &tot_moves);

	string row_str;
	for (int row = 1; row <= rows; row++) {
		cin >> row_str;
		grid[row] = bitset<N>(row_str, 0, row_str.length(), '#', '.');
		vis[0][row] = grid[row];
	}

	char moves[M];
	scanf("%s", moves + 1);

	for (int at_move = 1; at_move <= tot_moves; at_move++) {
		for (int row = 1; row <= rows; row++) vis[at_move % 2][row].reset();
		for (int row = 1; row <= rows; row++) {
			if (moves[at_move] == 'N' || moves[at_move] == '?') {
				vis[at_move % 2][row - 1] |= grid[row - 1] & vis[(at_move - 1) % 2][row];
			}
			if (moves[at_move] == 'S' || moves[at_move] == '?') {
				vis[at_move % 2][row + 1] |= grid[row + 1] & vis[(at_move - 1) % 2][row];
			}
			if (moves[at_move] == 'W' || moves[at_move] == '?') {
				vis[at_move % 2][row] |= grid[row] & (vis[(at_move - 1) % 2][row] << 1);
			}
			if (moves[at_move] == 'E' || moves[at_move] == '?') {
				vis[at_move % 2][row] |= grid[row] & (vis[(at_move - 1) % 2][row] >> 1);
			}
		}
	}

	int ans = 0;
	for (int row = 1; row <= rows; row++) ans += vis[tot_moves % 2][row].count();
	cout << ans << endl;

	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

nautilus.cpp: In function 'int main()':
nautilus.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &rows, &cols, &tot_moves);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", moves + 1);
  ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...