이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ppb pop_back
#define x first
#define y second
#define int long long
#define mp make_pair
#define cmpl complex <long double>
using namespace std;
const int sz = 5e5;
signed main (){
cin.tie(0);
ios_base::sync_with_stdio(0);
int n, m, k;
char x;
cin >> n >> m >> k;
bitset <sz> ans, pos1, pos2, p, temp;
for (int i = 0; i < n; ++i){
for (int j = 0; j < m; ++j){
cin >> x;
if (x == '.') ans[i * m + j] = 1;
p[i * m + j] = ans[i * m + j];
pos1[i * m + j] = (j != 0);
pos2[i * m + j] = (j != m - 1);
}
}
int res = 0;
string s;
cin >> s;
for (int i = 0; i < k; ++i){
temp = ans;
ans.reset();
if (s[i] == 'S' || s[i] == '?') ans |= (temp << m);
if (s[i] == 'N' || s[i] == '?') ans |= (temp >> m);
if (s[i] == 'E' || s[i] == '?') ans |= (temp << 1) & pos1;
if (s[i] == 'W' || s[i] == '?') ans |= (temp >> 1) & pos2;
ans = ans & p;
}
for (int i = 0; i < n; ++i){
for (int j = 0; j < m; ++j){
res += ans[i * m + j];
}
}
cout << res;
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... |