답안 #735753

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
735753 2023-05-04T14:45:47 Z MODDI Nautilus (BOI19_nautilus) C++14
66 / 100
251 ms 203768 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int r, c, n;
string str;
int mat[501][501];
int dp[101][501][501];
int main(){
	cin>>r>>c>>n;
	memset(dp, 0, sizeof dp);
	memset(mat, 0, sizeof mat);
	for(int i = 0; i < r; i++){
		string s;
		cin>>s;
		for(int j = 0; j < c; j++){
			if(s[j] == '.'){
				mat[i][j] = 1;
				dp[0][i][j] = 1;
			}
		}
	}
	cin>>str;
//	for(int i = 0; i < r; i++){
//		for(int j = 0; j < c; j++){
//			cout<<dp[0][i][j]<<" ";
//		}
//		cout<<endl;
//	}
//	cout<<endl;
	for(int step = 1; step <= n; step++){
		for(int i = 0; i < r; i++){
			for(int j = 0; j < c; j++){
				if((str[step-1] == 'E' || str[step-1] == '?') && mat[i][j] == 1 && dp[step-1][i][j-1] == 1 && j > 0)	
					dp[step][i][j] = 1;
				if((str[step-1] == 'W' || str[step-1] == '?') && mat[i][j] == 1 && dp[step-1][i][j+1] == 1 && j + 1 < c)
					dp[step][i][j] = 1;
				if((str[step-1] == 'N' || str[step-1] == '?') && i < r-1 && mat[i][j] == 1 && dp[step-1][i+1][j] == 1)
					dp[step][i][j] = 1;
				if((str[step-1]=='S' || str[step-1] == '?') && i > 0 && mat[i][j] == 1 && dp[step-1][i-1][j]==1)
					dp[step][i][j] = 1;
			}
		}
//		for(int i = 0; i < r; i++){
//			for(int j = 0; j < c; j++){
//				cout<<dp[step][i][j]<<" ";
//			}
//			cout<<endl;
//		}
//		cout<<endl;
	}
	ll ans = 0;
	for(int i = 0; i < r; i++){
		for(int j = 0; j < c;j ++){
			ans += dp[n][i][j];
		}
	}
	cout<<ans<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 100408 KB Output is correct
2 Correct 45 ms 100388 KB Output is correct
3 Correct 44 ms 100404 KB Output is correct
4 Correct 44 ms 100468 KB Output is correct
5 Correct 43 ms 100428 KB Output is correct
6 Correct 40 ms 100496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 100408 KB Output is correct
2 Correct 45 ms 100388 KB Output is correct
3 Correct 44 ms 100404 KB Output is correct
4 Correct 44 ms 100468 KB Output is correct
5 Correct 43 ms 100428 KB Output is correct
6 Correct 40 ms 100496 KB Output is correct
7 Correct 41 ms 100496 KB Output is correct
8 Correct 53 ms 100384 KB Output is correct
9 Correct 46 ms 100488 KB Output is correct
10 Correct 46 ms 100484 KB Output is correct
11 Correct 43 ms 100496 KB Output is correct
12 Correct 44 ms 100448 KB Output is correct
13 Correct 51 ms 100400 KB Output is correct
14 Correct 57 ms 100388 KB Output is correct
15 Correct 44 ms 100384 KB Output is correct
16 Correct 40 ms 100400 KB Output is correct
17 Correct 52 ms 100412 KB Output is correct
18 Correct 47 ms 100492 KB Output is correct
19 Correct 53 ms 100492 KB Output is correct
20 Correct 62 ms 100496 KB Output is correct
21 Correct 50 ms 100388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 100408 KB Output is correct
2 Correct 45 ms 100388 KB Output is correct
3 Correct 44 ms 100404 KB Output is correct
4 Correct 44 ms 100468 KB Output is correct
5 Correct 43 ms 100428 KB Output is correct
6 Correct 40 ms 100496 KB Output is correct
7 Correct 41 ms 100496 KB Output is correct
8 Correct 53 ms 100384 KB Output is correct
9 Correct 46 ms 100488 KB Output is correct
10 Correct 46 ms 100484 KB Output is correct
11 Correct 43 ms 100496 KB Output is correct
12 Correct 44 ms 100448 KB Output is correct
13 Correct 51 ms 100400 KB Output is correct
14 Correct 57 ms 100388 KB Output is correct
15 Correct 44 ms 100384 KB Output is correct
16 Correct 40 ms 100400 KB Output is correct
17 Correct 52 ms 100412 KB Output is correct
18 Correct 47 ms 100492 KB Output is correct
19 Correct 53 ms 100492 KB Output is correct
20 Correct 62 ms 100496 KB Output is correct
21 Correct 50 ms 100388 KB Output is correct
22 Runtime error 251 ms 203768 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -