Submission #834166

# Submission time Handle Problem Language Result Execution time Memory
834166 2023-08-22T11:26:30 Z BT21tata Nautilus (BOI19_nautilus) C++17
66 / 100
67 ms 158384 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;

unsigned short 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 1 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 1 ms 1364 KB Output is correct
14 Correct 1 ms 1364 KB Output is correct
15 Correct 1 ms 1364 KB Output is correct
16 Correct 1 ms 1364 KB Output is correct
17 Correct 1 ms 1364 KB Output is correct
18 Correct 1 ms 1364 KB Output is correct
19 Correct 1 ms 1364 KB Output is correct
20 Correct 1 ms 1364 KB Output is correct
21 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 1 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 1 ms 1364 KB Output is correct
14 Correct 1 ms 1364 KB Output is correct
15 Correct 1 ms 1364 KB Output is correct
16 Correct 1 ms 1364 KB Output is correct
17 Correct 1 ms 1364 KB Output is correct
18 Correct 1 ms 1364 KB Output is correct
19 Correct 1 ms 1364 KB Output is correct
20 Correct 1 ms 1364 KB Output is correct
21 Correct 1 ms 1364 KB Output is correct
22 Incorrect 67 ms 158384 KB Output isn't correct
23 Halted 0 ms 0 KB -