Submission #719883

# Submission time Handle Problem Language Result Execution time Memory
719883 2023-04-07T01:38:55 Z jamezzz Nautilus (BOI19_nautilus) C++17
100 / 100
134 ms 716 KB
#include <bits/stdc++.h>
using namespace std;

#define sf scanf
#define pf printf
#define INF 1023456789
#define maxn 505

int r,c,m;
bitset<maxn> grid[maxn],pos[maxn],pos2[maxn];

int main(){
	sf("%d%d%d",&r,&c,&m);
	for(int i=1;i<=r;++i){
		for(int j=1;j<=c;++j){
			char ch;sf(" %c",&ch);
			if(ch=='.'){
				grid[i].set(j,1);
				pos[i].set(j,1);
			}
		}
	}
	for(int i=0;i<m;++i){
		char ch;sf(" %c",&ch);
		for(int i=1;i<=r;++i){
			pos2[i].reset();
			if(ch=='W'||ch=='?'){
				pos2[i]|=(pos[i]>>1)&grid[i];
			}
			if(ch=='E'||ch=='?'){
				pos2[i]|=(pos[i]<<1)&grid[i];
			}
			if(ch=='N'||ch=='?'){
				pos2[i]|=pos[i+1]&grid[i];
			}
			if(ch=='S'||ch=='?'){
				pos2[i]|=pos[i-1]&grid[i];
			}
		}
		for(int i=1;i<=r;++i)pos[i]=pos2[i];
	}
	int ans=0;
	for(int i=1;i<=r;++i)ans+=pos[i].count();
	printf("%d\n",ans);
}

/*
5 9 7
...##....
..#.##..#
..#....##
.##...#..
....#....
WS?EE??
*/

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:13:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  sf("%d%d%d",&r,&c,&m);
      |    ^
nautilus.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |    char ch;sf(" %c",&ch);
      |              ^
nautilus.cpp:24:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   char ch;sf(" %c",&ch);
      |             ^
# 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 2 ms 308 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 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 2 ms 308 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 312 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 2 ms 340 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 2 ms 212 KB Output is correct
19 Correct 2 ms 308 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 308 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 2 ms 308 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 312 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 2 ms 340 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 2 ms 212 KB Output is correct
19 Correct 2 ms 308 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 308 KB Output is correct
22 Correct 74 ms 624 KB Output is correct
23 Correct 79 ms 628 KB Output is correct
24 Correct 74 ms 596 KB Output is correct
25 Correct 73 ms 604 KB Output is correct
26 Correct 78 ms 600 KB Output is correct
27 Correct 107 ms 612 KB Output is correct
28 Correct 114 ms 716 KB Output is correct
29 Correct 110 ms 628 KB Output is correct
30 Correct 110 ms 624 KB Output is correct
31 Correct 107 ms 596 KB Output is correct
32 Correct 134 ms 620 KB Output is correct
33 Correct 130 ms 624 KB Output is correct
34 Correct 132 ms 596 KB Output is correct
35 Correct 131 ms 624 KB Output is correct
36 Correct 130 ms 608 KB Output is correct