Submission #507380

# Submission time Handle Problem Language Result Execution time Memory
507380 2022-01-12T11:29:28 Z MurotY Nautilus (BOI19_nautilus) C++14
29 / 100
7 ms 372 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=555;
char a[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) {
		ans++; return ;
	}
	if (s[pos] == 'N' || s[pos] == '#') rec(x-1, y, pos+1);
	if (s[pos] == 'E' || s[pos] == '#') rec(x, y+1, pos+1);
	if (s[pos] == 'W' || s[pos] == '#') rec(x, y-1, pos+1);
	if (s[pos] == 'S' || s[pos] == '#') rec(x+1, y, pos+1);
	return ;
}
int main()
{
	ios;
	cin >> n >> m >> q;
	for (int i=0;i<n;i++) {
		for (int j=0;j<m;j++) cin >> a[i][j];
	}
	cin >> s;
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			if (a[i][j] != '#'){
		          rec(i, j, 0);
			}
		}
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 372 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 372 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Incorrect 1 ms 332 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 372 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Incorrect 1 ms 332 KB Output isn't correct
8 Halted 0 ms 0 KB -