이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
// #define int long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define kill(x) cout << x << endl, exit(0);
#define endl "\n"
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN = (int)500 + 7;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
int n, m, q, tmp, tmp2, tmp3, tmp4, ans, k, u, v, w, flag;
int arr[MAXN][MAXN], arr2[MAXN][MAXN];
// bool bad[MAXN][MAXN];
int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
int cnt[][4] = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}, {1, 1, 1, 1}};
string s; char ch;
bitset<MAXN*MAXN> bst, bad;
int32_t main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m >> k;
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++) {
cin >> ch;
if (ch == '.') bst[(i-1)*(m+1)+j] = bad[(i-1)*(m+1)+j] = 1;
}
}
cin >> s;
for (int i=0; i<k; i++) {
if (s[i] == 'N') {
bst = (bst>>(m+1)) & bad;
} else if (s[i] == 'S') {
bst = (bst<<(m+1)) & bad;
} else if (s[i] == 'E') {
bst = (bst<<1) & bad;
} else if (s[i] == 'W') {
bst = (bst>>1) & bad;
} else {
bst = ((bst>>(m+1)) | ((bst<<(m+1))) | (bst<<1) | (bst>>1))&bad;
}
}
cout << bst.count() << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |