Submission #139819

#TimeUsernameProblemLanguageResultExecution timeMemory
139819ae04071Nautilus (BOI19_nautilus)C++11
100 / 100
176 ms1016 KiB
#include <bits/stdc++.h> using namespace std; int n,m,l; bitset<500> dp[2][500]; char arr[501][501],str[5010]; bitset<500> ta[501]; int main() { scanf("%d%d%d",&n,&m,&l); for(int i=0;i<n;i++) { scanf("%s",arr[i]); for(int j=0;j<m;j++) ta[i][j] = arr[i][j]=='.'; } scanf("%s",str); for(int k=0;k<l;k++) { if(str[k]=='?') str[k] = 15; else if(str[k]=='S') str[k]=1; else if(str[k]=='N') str[k]=2; else if(str[k]=='W') str[k]=4; else str[k]=8; } for(int i=0;i<n;i++) dp[0][i] = ta[i]; int cur=1,pr=0; for(int k=0;k<l;k++) { for(int i=0;i<n;i++) dp[cur][i].reset(); for(int i=0;i<n;i++) { if(i && (str[k]&1)) dp[cur][i] |= dp[pr][i-1]; if(i<n-1 && (str[k]>>1&1)) dp[cur][i] |= dp[pr][i+1]; if(str[k]>>2&1) dp[cur][i] |= (dp[pr][i]>>1); if(str[k]>>3&1) dp[cur][i] |= (dp[pr][i]<<1); dp[cur][i] &= ta[i]; } swap(cur,pr); } int ans=0; for(int i=0;i<n;i++)for(int j=0;j<m;j++) if(dp[pr][i][j]) ans++; printf("%d\n",ans); return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&m,&l);
     ~~~~~^~~~~~~~~~~~~~~~~~~
nautilus.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s",arr[i]);
         ~~~~~^~~~~~~~~~~~~
nautilus.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",str);
     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...