Submission #496361

# Submission time Handle Problem Language Result Execution time Memory
496361 2021-12-21T06:24:41 Z AQ0212 Nautilus (BOI19_nautilus) C++17
0 / 100
3 ms 204 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <cstring>

#define ll long long int
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define all(x) x.begin(), x.end()

using namespace std;

ll inf2 = 3e18;

ll a[ 511 ][ 511 ], ans;
string s;

// void check(ll x, ll y, ll i, ll sz, ll n, ll m){
// 	if(a[ x ][ y ])
// 		return;
// 	if(i == sz){
// 		ans ++;
// 		return;
// 	}

// 	if(s[ i ] == '?'){
// 		if(x + 1 <= n)
// 			check(x + 1, y, i + 1, sz, n, m);
// 		if(x - 1 > 0)
// 			check(x - 1, y, i + 1, sz, n, m);
// 		if(y + 1 <= m)
// 			check(x, y + 1, i + 1, sz, n, m);
// 		if(y - 1 > 0)
// 			check(x, y - 1, i + 1, sz, n, m);
// 	}else if(s[ i ] == 'N'){
// 		if(x + 1 <= n)
// 			check(x + 1, y, i + 1, sz, n, m);
// 	}else if(s[ i ] == 'S'){
// 		if(x - 1 > 0)
// 			check(x - 1, y, i + 1, sz, n, m);
// 	}else if(s[ i ] == 'E'){
// 		if(y + 1 <= m)
// 			check(x, y + 1, i + 1, sz, n, m);
// 	}else if(s[ i ] == 'W'){
// 		if(y - 1 > 0)
// 			check(x, y - 1, i + 1, sz, n, m);
// 	}
// }

int main (){
    ll n, m, k;
	char c;

	cin >> n >> m >> k;

	for(int i = 1; i <= n; i ++){
		for(int j = 1; j <= m; j ++){
			cin >> c;
			if(c == '#')
				a[ i ][ j ] = 1;
		}
	}

	cin >> s;

	for(int i = 1; i <= n; i ++){
		for(int j = 1; j <= m; j ++){
			if(a[ i ][ j ])
				continue;

			// check(i, j, 0, k - 1, n, m);

			ll x = i, y = j, ch = 0;
			for(int t = 0; t < k; t ++){
				if(s[ t ] == 'N' && x - 1 > 0){
					if(!a[ x - 1 ][ y ])
						x --;
					else{
						ch ++;
						break;
					}
				}else if(s[ t ] == 'S' && x + 1 <= n){
					if(!a[ x + 1 ][ y ])
						x ++;
					else{
						ch ++;
						break;
					}
				}else if(s[ t ] == 'W' && y - 1 > 0){
					if(!a[ x ][ y - 1 ])
						y --;
					else{
						ch ++;
						break;
					}
				}else if(s[ t ] == 'E' && y + 1 <= m){
					if(!a[ x ][ y + 1 ])
						y ++;
					else{
						ch ++;
						break;
					}
				}
			}

			if(!ch)
				ans ++;
		}
	}

	cout << ans;
}


# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -