이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 515, MAXM = 6e3, MAXCELL = 3e5;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, m, t;
int a[MAXN][MAXN];
string operations;
bitset < MAXCELL > fr;
void read()
{
cin >> n >> m >> t;
char s;
m += 2; /// border 0
for (int i = 1; i <= n; ++ i)
{
for (int j = 1; j <= m-2; ++ j)
{
cin >> s;
if(s == '#')a[i][j] = 1;
else fr[(i - 1) * m + j] = 1;
}
}
cin >> operations;
operations = '+' + operations;
}
bitset < MAXCELL > bs[MAXM];
void solve()
{
bs[0] = fr;
for (int i = 1; i <= t; ++ i)
{
bs[i] = 0;
if(operations[i] == 'N')
{
bs[i] = (bs[i-1] >> m);
bs[i] = (bs[i] & fr);
}
if(operations[i] == 'S')
{
bs[i] = ((bs[i-1] << m) & fr);
bs[i] = (bs[i] & fr);
}
if(operations[i] == 'W' )
{
bs[i] = (bs[i-1] >> 1);
bs[i] = (bs[i] & fr);
}
if(operations[i] == 'E')
{
bs[i] = (bs[i-1] << 1);
bs[i] = (bs[i] & fr);
}
if(operations[i] == '?')
{
bs[i] = (((bs[i-1] << m) | (bs[i-1] >> 1)) | ((bs[i-1] << 1) | (bs[i-1] >> m)));
bs[i] = (bs[i] & fr);
}
}
bs[t] = (bs[t] & fr);
cout << bs[t].count() << endl;
}
int main()
{
speed();
read();
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... |