Submission #507278

# Submission time Handle Problem Language Result Execution time Memory
507278 2022-01-12T10:31:38 Z MurotY Nautilus (BOI19_nautilus) C++14
0 / 100
5 ms 6476 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 break;
					
				}
				if (res+mn1 >= 0){
					res=0;
					for (int j1=i+1;j1<=n;j1++){
						if (a[j1][j] == '.') res++;
						else break;
						
					}
					if (res >= mx1){
						res=0;
						for (int j1=j-1;j1>=0;j1--){
							if (a[i][j1] == '.') res++;
							else break;
						}
						if (res+mn >= 0){
							res=0;
							for (int j1=i+1;j1<m;j1++){
								if (a[i][j1] == '.') res++;
								else break;
							}
							if (res >= mx) ans++;
						}
					}
				} 
			}
		}
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6476 KB Output is correct
2 Incorrect 3 ms 6476 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6476 KB Output is correct
2 Incorrect 3 ms 6476 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6476 KB Output is correct
2 Incorrect 3 ms 6476 KB Output isn't correct
3 Halted 0 ms 0 KB -