이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 505;
const ll inf = 2e9;
const ll mod = 998244353;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
vector < bitset <M> > dp(M);
bitset <M> a[M];
string s;
int n, m, ans, len;
int main()
{
cin >> n >> m >> len;
for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j){
char c;
cin >> c;
if(c == '.') a[i][j] = 1, dp[i][j] = 1;
}
cin >> s;
for(int i = 0; i < len; ++i){
vector < bitset <M> > to(M);
for(int j = 1; j <= n; ++j){
if(s[i] == '?' || s[i] == 'N') to[j - 1] |= dp[j];
if(s[i] == '?' || s[i] == 'S') to[j + 1] |= dp[j];
if(s[i] == '?' || s[i] == 'E') to[j] |= (dp[j] << 1);
if(s[i] == '?' || s[i] == 'W') to[j] |= (dp[j] >> 1);
}
dp = to;
for(int j = 1; j <= n; ++j) dp[j] &= a[j];
}
for(int i = 1; i <= n; ++i) ans += dp[i].count();
cout << ans << 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... |