Submission #148111

#TimeUsernameProblemLanguageResultExecution timeMemory
148111WhipppedCreamNautilus (BOI19_nautilus)C++17
100 / 100
297 ms1400 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; #define X first #define Y second #define pb push_back typedef pair<int, int> ii; typedef long long ll; const int maxn = 505; const int maxs = 50005; const int sz = 500*500; int n, m, k; char arr[maxn][maxn]; char dir[maxs]; int main() { scanf("%d %d %d", &n, &m, &k); for(int i = 0; i< n; i++) scanf("%s", arr[i]); bitset<sz> mask; bitset<sz> mright, mleft; mright.set(); mleft.set(); for(int i = 0; i< n; i++) { for(int j = 0; j< m; j++) { if(arr[i][j] == '#') mask[i*m+j] = 0; else mask[i*m+j] = 1; if(j == 0) mleft[i*m+j] = 0; if(j == m-1) mright[i*m+j] = 0; } } bitset<sz> dp; for(int i = 0; i< n; i++) { for(int j = 0; j< m; j++) { dp[i*m+j] = 1; } } dp &= mask; // printf("%d\n", dp.count()); scanf("%s", dir); for(int i = 0; i< k; i++) { if(dir[i] == 'N') { dp = dp>>m; } else if(dir[i] == 'S') { dp = dp<<m; } else if(dir[i] == 'E') { dp = (dp<<1)&mleft; } else if(dir[i] == 'W') { dp = (dp>>1)&mright; } else { dp = (dp>>m)|(dp<<m)|((dp<<1)&mleft)|((dp>>1)&mright); } dp &= mask; } printf("%d\n", (int) dp.count()); }

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &m, &k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:21:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i< n; i++) scanf("%s", arr[i]);
                            ~~~~~^~~~~~~~~~~~~~
nautilus.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", dir);
  ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...