답안 #507369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
507369 2022-01-12T11:23:22 Z MurotY Nautilus (BOI19_nautilus) C++14
0 / 100
1 ms 716 KB
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long 
#define ff first
#define ss second
using namespace std;
const int N=5555;
char a[N][N];
bool u[N][N];
int n, m, q;
ll ans=0;
string s;
void rec(ll x, ll y, ll pos){
	if (x >= n || x < 0 || y >= m || y < 0 || a[x][y] == '#') return ;
//	cout << x <<" " << y <<" " << pos <<" " << q <<"\n"; 
	if (pos > q) {
		u[x][y]=1; return ;
	}
	if (s[pos] == 'N') rec(x-1, y, pos+1);
	if (s[pos] == 'E') rec(x, y+1, pos+1);
	if (s[pos] == 'W') rec(x, y-1, pos+1);
	if (s[pos] == 'S') rec(x+1, y, pos+1);
	return ;
}
int main()
{
	cin >> n >> m >> q;
	for (int i=0;i<n;i++) {
		for (int j=0;j<m;j++) cin >> a[i][j];
	}
	cin >> s;
	s=" "+s;
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			if (a[i][j] != '#'){
				if (i == 0 and j == 1) rec(i, j, 1);
			}
		}
	}
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++) if (u[i][j]) ans++;
	}
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -