Submission #159688

# Submission time Handle Problem Language Result Execution time Memory
159688 2019-10-24T00:55:04 Z DrSwad Nautilus (BOI19_nautilus) C++17
100 / 100
221 ms 760 KB
#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;
}

Compilation message

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 time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 3 ms 380 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 4 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 3 ms 380 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 4 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 124 ms 632 KB Output is correct
23 Correct 124 ms 700 KB Output is correct
24 Correct 121 ms 632 KB Output is correct
25 Correct 120 ms 632 KB Output is correct
26 Correct 119 ms 760 KB Output is correct
27 Correct 176 ms 632 KB Output is correct
28 Correct 179 ms 712 KB Output is correct
29 Correct 178 ms 708 KB Output is correct
30 Correct 179 ms 760 KB Output is correct
31 Correct 176 ms 712 KB Output is correct
32 Correct 221 ms 712 KB Output is correct
33 Correct 221 ms 760 KB Output is correct
34 Correct 221 ms 632 KB Output is correct
35 Correct 221 ms 632 KB Output is correct
36 Correct 221 ms 632 KB Output is correct