Submission #723463

# Submission time Handle Problem Language Result Execution time Memory
723463 2023-04-13T21:41:31 Z lovrot Nautilus (BOI19_nautilus) C++17
100 / 100
181 ms 616 KB
#include <cstdio>
#include <cstring>
#include <bitset>

using namespace std; 

const int N = 500; 

bitset<N> M[2][N + 2], S[N + 2];

int main() {
	int n, m, q;
	scanf("%d%d%d", &n, &m, &q); 
	for(int i = 1; i <= n; i++) 
		for(int j = 0; j < m; j++) {
			char c;
			scanf(" %c", &c);
			S[i].set(j, c == '.'); 
			M[0][i].set(j, c == '.'); 
		}
	bool f = 0;
	for(int t = 0; t < q; t++) {
		char c;
		scanf(" %c", &c); 
		f ^= 1;
		for(int i = 1; i <= n; i++) {
			if(c == 'W') M[f][i] = S[i] & (M[!f][i] >> 1);
			else if(c == 'E') M[f][i] = S[i] & (M[!f][i] << 1); 
			else if(c == 'N') M[f][i] = S[i] & M[!f][i + 1]; 
			else if(c == 'S') M[f][i] = S[i] & M[!f][i - 1]; 
			else M[f][i] = S[i] & ((M[!f][i] << 1) | (M[!f][i] >> 1) | M[!f][i - 1] | M[!f][i + 1]);
		}
	}
	int sol = 0; 
	for(int i = 1; i <= n; i++)
		sol += M[f][i].count();
	printf("%d\n", sol); 
	return 0;
}

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d%d", &n, &m, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:17:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |    scanf(" %c", &c);
      |    ~~~~~^~~~~~~~~~~
nautilus.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf(" %c", &c);
      |   ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 296 KB Output is correct
18 Correct 2 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 296 KB Output is correct
18 Correct 2 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 105 ms 360 KB Output is correct
23 Correct 108 ms 340 KB Output is correct
24 Correct 94 ms 596 KB Output is correct
25 Correct 96 ms 560 KB Output is correct
26 Correct 95 ms 608 KB Output is correct
27 Correct 135 ms 596 KB Output is correct
28 Correct 133 ms 612 KB Output is correct
29 Correct 136 ms 608 KB Output is correct
30 Correct 133 ms 616 KB Output is correct
31 Correct 144 ms 608 KB Output is correct
32 Correct 161 ms 612 KB Output is correct
33 Correct 173 ms 616 KB Output is correct
34 Correct 177 ms 596 KB Output is correct
35 Correct 181 ms 560 KB Output is correct
36 Correct 163 ms 616 KB Output is correct