Submission #898045

# Submission time Handle Problem Language Result Execution time Memory
898045 2024-01-04T08:57:13 Z vjudge1 Nautilus (BOI19_nautilus) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define pb push_back

#define TASKNAME "NAME"

void init()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ///freopen(TASKNAME".INP","r",stdin); freopen(TASKNAME".OUT","w",stdout);
}

const int SZ = 5e2+5;
const ll INF = INT_MAX / 2, MOD = 1e9+7, INFLL = 2e18;
const double epsilon = 1e-3;

int r,c,m;
#define bs bitset<502>
bs a[SZ], dp[SZ][2];
string s;
int res = 0;

int main()
{
    init();
    cin >> r >> c >> m;
    for(int i = 1; i <= r; i++)
    {
        for(int j = 1; j <= c; j++)
        {
            char p;
            cin >> p;
            if(p == '.')
            {
                a[i].set(j);
                dp[i][0].set(j);
            }
        }
    }
    cin >> s;
    s = " " + s;
    for(int k = 1; k <= m; k++)
    {
        int j = k % 2;
        for(int i = 1; i <= r; i++)
        {
            if(i > 1 && ( s[k] == 'S' || s[k] == '?' )) dp[i][j] |= ( a[i] & dp[i - 1][j ^ 1] );
            if(i < r && ( s[k] == 'N' || s[k] == '?' )) dp[i][j] |= ( a[i] & dp[i + 1][j ^ 1] );
            if( s[k] == 'E' || s[k] == '?' ) dp[i][j] |= ( a[i] & (dp[i][j ^ 1] >> 1) );
            if( s[k] == 'W' || s[k] == '?' ) dp[i][j] |= ( a[i] & (dp[i][j ^ 1] << 1) );
        }
    }
    for(int i = 1; i <= r; i++)
    {
        res += dp[i][ m % 2 ].count();
    }
    cout << res;
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -