Submission #1021818

#TimeUsernameProblemLanguageResultExecution timeMemory
1021818AlmontherNautilus (BOI19_nautilus)C++98
29 / 100
1066 ms348 KiB
#include <bits/stdc++.h> #define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll long long #define co cout<< //#pragma GCC optimize("O3,Ofast,unroll-loops") //#pragma GCC target("avx2,sse3,sse4,avx") using namespace std; //stuff ll n,m,q; string s[105]; string que; ll vis[105][105]; void rec(ll i,ll j,ll idx){ if(i>=n||i<0||j>=m||j<0) return; if(s[i][j]=='#') return; if(idx==q){ vis[i][j]=1; return; } if(que[idx]=='N'||que[idx]=='?') rec(i-1,j,idx+1); if(que[idx]=='S'||que[idx]=='?') rec(i+1,j,idx+1); if(que[idx]=='E'||que[idx]=='?') rec(i,j+1,idx+1); if(que[idx]=='W'||que[idx]=='?') rec(i,j-1,idx+1); } void solve(){ cin>>n>>m>>q; for(int i=0;i<n;i++) cin>>s[i]; cin>>que; ll cnt=0; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ rec(i,j,0); } } for(int i=0;i<n;i++) for(int j=0;j<m;j++) cnt+=vis[i][j]; co cnt<<'\n'; } int main() { suiii int tt=1; // cin>>tt; while(tt--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...