답안 #496376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496376 2021-12-21T06:37:32 Z Mukhitali Nautilus (BOI19_nautilus) C++17
0 / 100
2 ms 332 KB
//bit chass 1
#include <bits/stdc++.h>

#define x first
#define y second
#define el "\n"
#define ll long long
#define pb push_back
#define pll pair <ll, ll>
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define lcm(x,y) x * y / __gcd(x, y)
#define ibase ios_base::sync_with_stdio(0), cin.tie(0)

using namespace std;

const int N = 3e5 + 5, inf = 1e9 + 7, M = 2e6, MM = 2e6 + 5, K = 300;
const ll MI = 2e18;
const double P = 3.14;

string s[505];

void solve() {
	int r, c, m, x = 0, y = 0;
	cin >> r >> c >> m;
	for (int i = 0; i < r; i++)
		cin >> s[i];
	int ans= 0;
	string a;
	cin >> a;
	for (int i = 0; i < m; i++) {
		if (a[i] == 'N')
			x--;
		if (a[i] == 'S')
			x++;
		if (a[i] == 'W')
			y--;
		if (a[i] == 'E')
			y++;
	}
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			if (0 <= i + x && i + x < r && 0 <= j + y && j + y < c) {
				bool ok = 0;
				int q = i, w = j;
				for (int k = 0; k < m; k++) {
					if (a[k] == 'N') {
						if (q == 0 || s[q - 1][w] == '#')
							break;
						q--;
					}
					if (a[k] == 'S') {
						q++;
						if (q == r || s[q][w] == '#')
							break;
					}
					if (a[k] == 'W') {
						if (w == 0 || s[q][w - 1] == '#')
							break;
						w--;
					}
					if (a[k] == 'E') {
						w++;
						if (w == c || s[q][w] == '#')
							break;
					}
					if (k == m - 1)
						ok = 1;
				}
				if (ok)
					ans++;
			}
		}
	}
	cout << ans;
}

int main() {
	ibase;
	int T = 1;
//	cin >> T;
	for (int i = 1; i <= T; i++) {
//		cout << "Case " << i << ": ";
		solve();
		cout << el;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -