Submission #834156

# Submission time Handle Problem Language Result Execution time Memory
834156 2023-08-22T11:20:22 Z BT21tata Nautilus (BOI19_nautilus) C++17
100 / 100
224 ms 158832 KB
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// #pragma GCC target ("avx,avx2,fma")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define SPEED ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0)
#define rall(v) (v).rbegin(),(v).rend()
#define all(v) (v).begin(),(v).end()
#define setp fixed<<setprecision
#define OK cerr<<"OK"<<endl<<flush
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define F first
#define S second
#define y0 jahdakdh
#define y1 jahsadakdakdh
#define endl '\n'
const ll MOD=1e9+7;
const ll mod=(1ll<<31)-1;
const ld eps=1e-8;
const ll MAXLONG=9223372036854775807;
const ll MINLONG=-9223372036854775807;
using namespace std;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
const int N=1e5+5;

int n, m, k, ans;
string s;
bitset<505>a[505], dp[5005][505];

int main()
{
    SPEED;
    cin>>n>>m>>k;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            char x; cin>>x;
            if(x=='.') a[i][j]=1, dp[0][i][j]=1;
        }
    }
    cin>>s; 
    for(int i=1; i<=k; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(s[i-1]=='N') dp[i][j]=dp[i-1][j+1]&a[j];
            else if(s[i-1]=='S') dp[i][j]=dp[i-1][j-1]&a[j];
            else if(s[i-1]=='W') dp[i][j]=(dp[i-1][j]>>1)&a[j];
            else if(s[i-1]=='E') dp[i][j]=(dp[i-1][j]<<1)&a[j];
            else dp[i][j]=(dp[i-1][j+1]|dp[i-1][j-1]|(dp[i-1][j]>>1)|(dp[i-1][j]<<1))&a[j];
        }
    }
    for(int i=0; i<n; i++)
    {
        ans+=dp[k][i].count();
    }
    cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 2 ms 1364 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1364 KB Output is correct
13 Correct 2 ms 1368 KB Output is correct
14 Correct 2 ms 1364 KB Output is correct
15 Correct 2 ms 1364 KB Output is correct
16 Correct 1 ms 1364 KB Output is correct
17 Correct 2 ms 1360 KB Output is correct
18 Correct 2 ms 1364 KB Output is correct
19 Correct 2 ms 1364 KB Output is correct
20 Correct 2 ms 1364 KB Output is correct
21 Correct 2 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 2 ms 1364 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1364 KB Output is correct
13 Correct 2 ms 1368 KB Output is correct
14 Correct 2 ms 1364 KB Output is correct
15 Correct 2 ms 1364 KB Output is correct
16 Correct 1 ms 1364 KB Output is correct
17 Correct 2 ms 1360 KB Output is correct
18 Correct 2 ms 1364 KB Output is correct
19 Correct 2 ms 1364 KB Output is correct
20 Correct 2 ms 1364 KB Output is correct
21 Correct 2 ms 1368 KB Output is correct
22 Correct 123 ms 158756 KB Output is correct
23 Correct 128 ms 158832 KB Output is correct
24 Correct 122 ms 158756 KB Output is correct
25 Correct 124 ms 158652 KB Output is correct
26 Correct 120 ms 158596 KB Output is correct
27 Correct 179 ms 158748 KB Output is correct
28 Correct 185 ms 158640 KB Output is correct
29 Correct 181 ms 158668 KB Output is correct
30 Correct 181 ms 158752 KB Output is correct
31 Correct 180 ms 158640 KB Output is correct
32 Correct 221 ms 158656 KB Output is correct
33 Correct 221 ms 158708 KB Output is correct
34 Correct 223 ms 158692 KB Output is correct
35 Correct 222 ms 158640 KB Output is correct
36 Correct 224 ms 158612 KB Output is correct