답안 #507276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
507276 2022-01-12T10:27:56 Z MurotY Nautilus (BOI19_nautilus) C++14
0 / 100
6 ms 6560 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=2*1e5+7;
string a[N];
int main()
{
	int n, m, q;
	cin >> n >> m >> q;
	for (int i=1;i<=n;i++) cin >> a[i];
	string s;
	cin >> s;
	int mx=0, mn=1e9, mx1=0, mn1=1e9, res=0, res1=0;
	for (int i=0;i<q;i++){
		if (s[i] == 'E') res++;
		if (s[i] == 'W') res--;
		if (s[i] == 'N') res1++;
		if (s[i] == 'S') res1--;
		mn=min(mn, res);
		mx=max(mx, res);
		mn1=min(mn1, res1);
		mx1=max(mx1, res1);
	}
	res=res1=0;
	ll ans=0;
	for (int i=1;i<=n;i++){
		for (int j=0;j<m;j++){
			if (a[i][j] == '.'){
				res=res1=0;
				for (int j1=i-1;j1>0;j1--){
					if (a[j1][j] == '.') res++;
					else {
						res=0;
						break;
					}
				}
				if (res+mn1 >= 0){
					res=0;
					for (int j1=i+1;j1<=n;j1++){
						if (a[j1][j] == '.') res++;
						else {
							res=0;
							break;
						}
					}
					if (res >= mx1){
						res=0;
						for (int j1=j-1;j1>=0;j1--){
							if (a[i][j1] == '.') res++;
							else {
								res=0;
								break;
							}
						}
						if (res+mn >= 0){
							res=0;
							for (int j1=i+1;j1<m;j1++){
								if (a[i][j1] == '.') res++;
								else {
									res=0;
									break;
								}
							}
							if (res >= mx) ans++;
						}
					}
				} 
			}
		}
	}
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6476 KB Output is correct
2 Incorrect 5 ms 6560 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6476 KB Output is correct
2 Incorrect 5 ms 6560 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6476 KB Output is correct
2 Incorrect 5 ms 6560 KB Output isn't correct
3 Halted 0 ms 0 KB -