Submission #1178879

#TimeUsernameProblemLanguageResultExecution timeMemory
1178879xtlNautilus (BOI19_nautilus)C++20
100 / 100
151 ms648 KiB
#include <bits/stdc++.h>
using namespace std;
int R, C, M;
string s;
bitset<1000> original[500];
bitset<1000> dp[500];
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> R >> C >> M;
    for (int i = 0; i < R; i++)
    {
        string r;
        cin >> r;
        for (int j = 0; j < C; j++)
            if (r[j] == '.')
                original[i][j + 500] = 1;
        dp[i] = original[i];
    }
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        bitset<1000> temp[500];
        if (s[i] == '?' || s[i] == 'W')
            for (int j = 0; j < R; j++)
                temp[j] = (dp[j] >> 1);
        if (s[i] == '?' || s[i] == 'E')
            for (int j = 0; j < R; j++)
                temp[j] |= (dp[j] << 1);
        if (s[i] == '?' || s[i] == 'N')
            for (int j = 0; j < R - 1; j++)
                temp[j] |= dp[j + 1];
        if (s[i] == '?' || s[i] == 'S')
            for (int j = 1; j < R; j++)
                temp[j] |= dp[j - 1];
        for (int j = 0; j < R; j++)
            dp[j] = temp[j] & original[j];
    }
    int ans = 0;
    for (int i = 0; i < R; i++)
        ans += dp[i].count();
    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...