답안 #719587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
719587 2023-04-06T10:14:24 Z jamezzz Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 3412 KB
#include <bits/stdc++.h>
using namespace std;

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

int r,c,m,grid[maxn][maxn],pos[maxn][maxn],pos2[maxn][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][j]=1;
				pos[i][j]=1;
			}
		}
	}
	for(int i=0;i<m;++i){
		char ch;sf(" %c",&ch);
		vector<pair<int,int>> dir;
		if(ch=='W'||ch=='?')dir.push_back({0,1});
		if(ch=='E'||ch=='?')dir.push_back({0,-1});
		if(ch=='N'||ch=='?')dir.push_back({1,0});
		if(ch=='S'||ch=='?')dir.push_back({-1,0});
		for(int i=1;i<=r;++i){
			for(int j=1;j<=c;++j){
				pos2[i][j]=0;
				for(auto[dx,dy]:dir){
					if(grid[i][j]&&pos[i+dx][j+dy]){
						pos2[i][j]=1;
					}
				}
			}
		}
		for(int i=1;i<=r;++i){
			for(int j=1;j<=c;++j)pos[i][j]=pos2[i][j];
		}
		/*
		printf("\n");
		for(int i=1;i<=r;++i){
			for(int j=1;j<=c;++j)printf("%d",pos[i][j]);
			printf("\n");
		}
		printf("\n");
		*/
	}
	int ans=0;
	for(int i=1;i<=r;++i){
		for(int j=1;j<=c;++j)ans+=pos[i][j];
	}
	printf("%d\n",ans);
}

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

Compilation message

nautilus.cpp: In function 'int main()':
nautilus.cpp:12:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  sf("%d%d%d",&r,&c,&m);
      |    ^
nautilus.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |    char ch;sf(" %c",&ch);
      |              ^
nautilus.cpp:23:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   char ch;sf(" %c",&ch);
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 852 KB Output is correct
2 Correct 6 ms 852 KB Output is correct
3 Correct 6 ms 852 KB Output is correct
4 Correct 6 ms 824 KB Output is correct
5 Correct 4 ms 852 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 852 KB Output is correct
2 Correct 6 ms 852 KB Output is correct
3 Correct 6 ms 852 KB Output is correct
4 Correct 6 ms 824 KB Output is correct
5 Correct 4 ms 852 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Correct 4 ms 828 KB Output is correct
8 Correct 10 ms 852 KB Output is correct
9 Correct 8 ms 852 KB Output is correct
10 Correct 6 ms 852 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 8 ms 852 KB Output is correct
13 Correct 14 ms 920 KB Output is correct
14 Correct 16 ms 852 KB Output is correct
15 Correct 7 ms 852 KB Output is correct
16 Correct 4 ms 724 KB Output is correct
17 Correct 8 ms 852 KB Output is correct
18 Correct 14 ms 916 KB Output is correct
19 Correct 16 ms 852 KB Output is correct
20 Correct 9 ms 852 KB Output is correct
21 Correct 5 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 852 KB Output is correct
2 Correct 6 ms 852 KB Output is correct
3 Correct 6 ms 852 KB Output is correct
4 Correct 6 ms 824 KB Output is correct
5 Correct 4 ms 852 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Correct 4 ms 828 KB Output is correct
8 Correct 10 ms 852 KB Output is correct
9 Correct 8 ms 852 KB Output is correct
10 Correct 6 ms 852 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 8 ms 852 KB Output is correct
13 Correct 14 ms 920 KB Output is correct
14 Correct 16 ms 852 KB Output is correct
15 Correct 7 ms 852 KB Output is correct
16 Correct 4 ms 724 KB Output is correct
17 Correct 8 ms 852 KB Output is correct
18 Correct 14 ms 916 KB Output is correct
19 Correct 16 ms 852 KB Output is correct
20 Correct 9 ms 852 KB Output is correct
21 Correct 5 ms 724 KB Output is correct
22 Execution timed out 1085 ms 3412 KB Time limit exceeded
23 Halted 0 ms 0 KB -