Submission #419882

#TimeUsernameProblemLanguageResultExecution timeMemory
419882nicolaalexandraNautilus (BOI19_nautilus)C++14
100 / 100
178 ms716 KiB
#include <bits/stdc++.h> #define DIM 510 using namespace std; char v[DIM*10],s[DIM]; int n,m,k,i,j; bitset <DIM> a[2][DIM],mask[DIM]; int main (){ //ifstream cin ("date.in"); //ofstream cout ("date.out"); cin>>n>>m>>k; for (i=1;i<=n;i++){ cin>>s+1; for (j=1;j<=m;j++) if (s[j] == '.') mask[i][j] = 1; a[0][i] = mask[i]; } cin>>v+1; int t = 1; for (int pas=1;pas<=k;pas++){ for (i=1;i<=n;i++) a[t][i].reset(); for (i=1;i<=n;i++){ if (v[pas] == 'N' || v[pas] == '?') a[t][i] |= a[1-t][i+1]; if (v[pas] == 'S' || v[pas] == '?') a[t][i] |= a[1-t][i-1]; if (v[pas] == 'E' || v[pas] == '?') a[t][i] |= (a[1-t][i] << 1); if (v[pas] == 'W' || v[pas] == '?') a[t][i] |= (a[1-t][i] >> 1); a[t][i] &= mask[i]; } t = 1-t; } int sol = 0; for (i=1;i<=n;i++) for (j=1;j<=m;j++) sol += a[1-t][i][j]; cout<<sol; return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:18:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   18 |         cin>>s+1;
      |              ~^~
nautilus.cpp:26:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |     cin>>v+1;
      |          ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...