제출 #1157128

#제출 시각아이디문제언어결과실행 시간메모리
1157128LmaoLmaoNautilus (BOI19_nautilus)C++20
100 / 100
193 ms157200 KiB
#include<bits/stdc++.h>
#define fi first
#define se second
#define int long long
using namespace std;

using ll = long long;
using ii = pair<ll, ll>;
using aa = array<int,4>;

const int N = 1e6+5;
const int INF = 1e9;
const int MOD = 1e5+3;

bitset<505> dp[505][5005];
bitset<505> a[505];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    int n,m,l;
    cin >> n >> m >> l;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) {
            char c;
            cin >> c;
            a[i] <<= 1;
            if(c=='.') {
                a[i]|=1;
            }
        }
        dp[i][0]=a[i];
        //cout << dp[i][0] << endl;
    }
    //cout << endl;
    string s;
    cin >> s;
    s='.'+s;
    int ans=0;
    for(int j=1;j<=l;j++) {
        for(int i=1;i<=n;i++) {   
            if(s[j]=='W') {
                dp[i][j]=(dp[i][j-1] << 1) & a[i];
            }
            if(s[j]=='E') {
                dp[i][j]=(dp[i][j-1] >> 1) & a[i];
            }
            if(s[j]=='N') {
                dp[i][j]=dp[i+1][j-1] & a[i];
            }
            if(s[j]=='S') {
                dp[i][j]=dp[i-1][j-1] & a[i];
            }
            if(s[j]=='?') {
                dp[i][j]=((dp[i][j-1] << 1) | (dp[i][j-1] >> 1) | dp[i-1][j-1] | dp[i+1][j-1]) & a[i];
            }
            //cout << dp[i][j] << endl;
            if(j==l) ans+=dp[i][j].count();
        }
        //cout << endl;
    }
    cout << ans;
    return 0;
}
 
/*
██╗░░██╗██╗░░██╗░█████╗░███╗░░██╗░██████╗░              ░██████╗██╗██╗░░░██╗                ░█████╗░██╗░░░██╗████████╗███████╗
██║░██╔╝██║░░██║██╔══██╗████╗░██║██╔════╝░              ██╔════╝██║██║░░░██║                ██╔══██╗██║░░░██║╚══██╔══╝██╔════╝
█████═╝░███████║███████║██╔██╗██║██║░░██╗░              ╚█████╗░██║██║░░░██║                ██║░░╚═╝██║░░░██║░░░██║░░░█████╗░░
██╔═██╗░██╔══██║██╔══██║██║╚████║██║░░╚██╗              ░╚═══██╗██║██║░░░██║                ██║░░██╗██║░░░██║░░░██║░░░██╔══╝░░
██║░╚██╗██║░░██║██║░░██║██║░╚███║╚██████╔╝              ██████╔╝██║╚██████╔╝                ╚█████╔╝╚██████╔╝░░░██║░░░███████╗
╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚══╝░╚═════╝░              ╚═════╝░╚═╝░╚═════╝░                ░╚════╝░░╚═════╝░░░░╚═╝░░░╚══════╝
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...