Submission #860213

#TimeUsernameProblemLanguageResultExecution timeMemory
860213ReLiceNautilus (BOI19_nautilus)C++17
100 / 100
173 ms160364 KiB
#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<260005>> dp(5005); void solve(){ ll i,j,q; ll c=0; ll n,m,k; cin>>n>>m>>k; c+=m+2; for(i=1;i<=n;i++){ c++; for(j=1;j<=m;j++){ cin>>ch[i][j]; if(ch[i][j]=='.')dp[0][c]=true; c++; } c++; } str s; cin>>s; for(i=1;i<=(ll)s.sz;i++){ if(s[i-1]=='N') dp[i]=dp[0]&(dp[i-1]>>(m+2)); if(s[i-1]=='S') dp[i]=dp[0]&(dp[i-1]<<(m+2)); if(s[i-1]=='W') dp[i]=dp[0]&(dp[i-1]>>1); if(s[i-1]=='E') dp[i]=dp[0]&(dp[i-1]<<1); if(s[i-1]=='?') dp[i]=((dp[i-1]<<(m+2))|(dp[i-1]>>(m+2))|(dp[i-1]<<1)|(dp[i-1]>>1))&(dp[0]); } cout<<dp[s.sz].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)

nautilus.cpp: In function 'void solve()':
nautilus.cpp:37:12: warning: unused variable 'q' [-Wunused-variable]
   37 |     ll i,j,q;
      |            ^
nautilus.cpp: In function 'void fre(std::string)':
nautilus.cpp:24:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:24:64: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...