This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int r, c, m;
cin >> r >> c >> m;
vector<bitset<502> > isl(r + 2);
for(int i = 0; i <= r + 1; i++)
{
for(int j = 0; j <= c + 1; j++)
{
if(i == 0 || i == r + 1 || j == 0 || j == c + 1)
{
isl[i][j] = 1;
continue;
}
char c;
cin >> c;
isl[i][j] = (c == '#');
}
}
vector<bitset<502> > bad = isl, bad2(r + 2);
string s;
cin >> s;
for(auto z : s)
{
for(int i = 0; i <= r + 1; i++)
{
bad2[i] = isl[i];
if(i == 0 || i == r + 1) continue;
if(z == 'N')
{
bad2[i] |= bad[i + 1];
}
else if(z == 'S')
{
bad2[i] |= bad[i - 1];
}
else if(z == 'E')
{
bad2[i] |= (bad[i] << 1);
}
else if(z == 'W')
{
bad2[i] |= (bad[i] >> 1);
}
else if(z == '?')
{
bad2[i] = bad[i - 1] & bad[i + 1] & (bad[i] << 1) & (bad[i] >> 1);
bad2[i] |= isl[i];
}
//for(int j = 1; j <= c; j++) cout << 1 - bad2[i][j] << " ";
//cout << "\n";
}
//cout << "\n";
bad = bad2;
}
int ans = 0;
for(int i = 1; i <= r; i++)
{
for(int j = 1; j <= c; j++)
{
ans += 1 - bad[i][j];
}
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |