Submission #900602

# Submission time Handle Problem Language Result Execution time Memory
900602 2024-01-08T15:43:00 Z mraron Nautilus (BOI19_nautilus) C++14
100 / 100
165 ms 157520 KB
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair
#define ins insert

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

using ll = long long;
using ull = unsigned long long ;
using ld = long double ;
using str = string;
//using ordered_set=tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
    T val=0;
    char c;
    
    bool neg=false;
    while((c=gc()) && !(c>='0' && c<='9')) {
        neg|=c=='-';
    }

    do {
        val=(val*10)+c-'0';
    } while((c=gc()) && (c>='0' && c<='9'));

    return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int n,m,k;
string t[501];
bitset<501> dp[501][5001];

int main() {
    IO;
    cin>>n>>m>>k;
    for(int i=0;i<n;++i) cin>>t[i];
    
    for(int i=0;i<n;++i) {
        for(int j=0;j<m;++j) {
            if(t[i][j]=='.') dp[i][0][j]=1;
        }
    }
    string s;
    cin>>s;
    for(int i=1;i<=sz(s);++i) {
       bool q=s[i-1]=='?';
       if(q||s[i-1]=='S')
            for(int r=1;r<n;++r) {
                dp[r][i]|=dp[r-1][i-1];
            }
       if(q||s[i-1]=='N')
            for(int r=0;r+1<n;++r) {
                dp[r][i]|=dp[r+1][i-1];
            }
       if(q||s[i-1]=='W')
            for(int r=0;r<n;++r) {
                dp[r][i]|=dp[r][i-1]>>1;
            }
       if(q||s[i-1]=='E') 
            for(int r=0;r<n;++r) {
                dp[r][i]|=dp[r][i-1]<<1;
            }
        for(int r=0;r<n;++r) {
            dp[r][i]&=dp[r][0];
        }
        //~ for(int r=0;r<n;++r){
            //~ for(int j=0;j<m;++j) {
                //~ cerr<<dp[r][i][j]<<" ";
            //~ }cerr<<"\n";
        //~ }
    }
    
    int ans=0;
    for(int i=0;i<n;++i) {
        ans+=dp[i][sz(s)].count();
    }
    cout<<ans<<"\n";
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 33116 KB Output is correct
2 Correct 4 ms 33116 KB Output is correct
3 Correct 4 ms 33116 KB Output is correct
4 Correct 4 ms 33116 KB Output is correct
5 Correct 4 ms 33116 KB Output is correct
6 Correct 6 ms 33116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 33116 KB Output is correct
2 Correct 4 ms 33116 KB Output is correct
3 Correct 4 ms 33116 KB Output is correct
4 Correct 4 ms 33116 KB Output is correct
5 Correct 4 ms 33116 KB Output is correct
6 Correct 6 ms 33116 KB Output is correct
7 Correct 4 ms 33112 KB Output is correct
8 Correct 4 ms 33112 KB Output is correct
9 Correct 5 ms 33116 KB Output is correct
10 Correct 4 ms 33116 KB Output is correct
11 Correct 2 ms 5468 KB Output is correct
12 Correct 4 ms 33116 KB Output is correct
13 Correct 4 ms 33116 KB Output is correct
14 Correct 4 ms 33112 KB Output is correct
15 Correct 5 ms 33112 KB Output is correct
16 Correct 2 ms 5468 KB Output is correct
17 Correct 4 ms 33332 KB Output is correct
18 Correct 4 ms 33116 KB Output is correct
19 Correct 4 ms 33116 KB Output is correct
20 Correct 4 ms 33116 KB Output is correct
21 Correct 4 ms 33116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 33116 KB Output is correct
2 Correct 4 ms 33116 KB Output is correct
3 Correct 4 ms 33116 KB Output is correct
4 Correct 4 ms 33116 KB Output is correct
5 Correct 4 ms 33116 KB Output is correct
6 Correct 6 ms 33116 KB Output is correct
7 Correct 4 ms 33112 KB Output is correct
8 Correct 4 ms 33112 KB Output is correct
9 Correct 5 ms 33116 KB Output is correct
10 Correct 4 ms 33116 KB Output is correct
11 Correct 2 ms 5468 KB Output is correct
12 Correct 4 ms 33116 KB Output is correct
13 Correct 4 ms 33116 KB Output is correct
14 Correct 4 ms 33112 KB Output is correct
15 Correct 5 ms 33112 KB Output is correct
16 Correct 2 ms 5468 KB Output is correct
17 Correct 4 ms 33332 KB Output is correct
18 Correct 4 ms 33116 KB Output is correct
19 Correct 4 ms 33116 KB Output is correct
20 Correct 4 ms 33116 KB Output is correct
21 Correct 4 ms 33116 KB Output is correct
22 Correct 122 ms 157456 KB Output is correct
23 Correct 114 ms 157352 KB Output is correct
24 Correct 108 ms 157520 KB Output is correct
25 Correct 106 ms 157508 KB Output is correct
26 Correct 144 ms 157488 KB Output is correct
27 Correct 128 ms 157476 KB Output is correct
28 Correct 128 ms 157520 KB Output is correct
29 Correct 116 ms 157388 KB Output is correct
30 Correct 120 ms 157472 KB Output is correct
31 Correct 165 ms 157520 KB Output is correct
32 Correct 139 ms 157472 KB Output is correct
33 Correct 138 ms 157520 KB Output is correct
34 Correct 137 ms 157340 KB Output is correct
35 Correct 152 ms 157500 KB Output is correct
36 Correct 135 ms 157332 KB Output is correct