# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
860194 | ReLice | Nautilus (BOI19_nautilus) | C++14 | 21 ms | 153692 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll int
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define sz size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define bc back()
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
const long long inf=1e18+7;
const ll mod=998244353;
const ll N=130*2;;
const ld eps=1e-9;
char ch[505][505];
vector <bitset<250005>> dp(5005);
void solve(){
ll i,j;
ll b,c=1;
ll n,m,k;
cin>>n>>m>>k;
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
cin>>ch[i][j];
dp[0][c]=true;
c++;
}
}
str s;
cin>>s;
for(i=1;i<=s.sz;i++){
if(s[i-1]=='N') dp[i]=dp[i-1]&(dp[i-1]<<m);
if(s[i-1]=='S') dp[i]=dp[i-1]&(dp[i-1]>>m);
if(s[i-1]=='W') dp[i]=dp[i-1]&(dp[i-1]<<1);
if(s[i-1]=='E') dp[i]=dp[i-1]&(dp[i-1]>>1);
if(s[i-1]=='?') dp[i]=(dp[i-1]&(dp[i-1]<<m))|(dp[i-1]&(dp[i-1]>>m))|(dp[i-1]&(dp[i-1]<<1))|(dp[i-1]&(dp[i-1]>>1));
}
cout<<dp[i].count()<<endl;
}
signed main(){
start();
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ll t=1;
//cin>>t;
while(t--) solve();
}
/*
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |