이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 510;
int n, m, l;
bitset < maxn > bt[maxn], base[maxn], cur[maxn], pos[maxn];
void go_north()
{
for (int i = 0; i <= n + 1; i ++)
pos[i] = bt[i + 1];
for (int i = 0; i <= n + 1; i ++)
cur[i] = (cur[i] | pos[i]);
}
void go_south()
{
for (int i = 1; i <= n + 1; i ++)
pos[i] = bt[i - 1];
for (int i = 0; i <= n + 1; i ++)
cur[i] = (cur[i] | pos[i]);
}
void go_east()
{
for (int i = 0; i <= n + 1; i ++)
pos[i] = (bt[i] << 1);
for (int i = 0; i <= n + 1; i ++)
cur[i] = (cur[i] | pos[i]);
}
void go_west()
{
for (int i = 0; i <= n + 1; i ++)
pos[i] = (bt[i] >> 1);
for (int i = 0; i <= n + 1; i ++)
cur[i] = (cur[i] | pos[i]);
}
void solve()
{
cin >> n >> m >> l;
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++)
{
char c;
cin >> c;
if (c == '.')
bt[i][j] = 1, base[i][j] = 1;
}
for (int t = 1; t <= l; t ++)
{
for (int i = 0; i <= n + 1; i ++)
cur[i].reset();
char c;
cin >> c;
if (c == 'N' || c =='?')
go_north();
if (c == 'E' || c == '?')
go_east();
if (c == 'S' || c == '?')
go_south();
if (c == 'W' || c == '?')
go_west();
/**for (int i = 1; i <= n; i ++, cout << endl)
for (int j = 1; j <= m; j ++)
cout << bt[i][j];
cout << "---------------" << endl;*/
for (int i = 0; i <= n + 1; i ++)
bt[i] = cur[i], bt[i] = (bt[i] & base[i]);
}
int ans = 0;
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++)
ans += bt[i][j];
cout << ans << endl;
}
int main()
{
solve();
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... |