Submission #1088923

#TimeUsernameProblemLanguageResultExecution timeMemory
1088923CadocNautilus (BOI19_nautilus)C++14
100 / 100
166 ms1112 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define el cout << '\n' #define N 505 int n, m, k; string s; char c[N][N]; bitset<N> dp[2][N], f[N]; void Solve(){ cin >> n >> m >> k; for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j) cin >> c[i][j]; cin >> s; s = ' ' + s; for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j) dp[0][i][j] = f[i][j] = (c[i][j] == '.'); for(int t=1; t<=k; ++t){ char x = s[t]; if(x == 'N') for(int i=n-1; i; --i) dp[1][i] |= dp[0][i+1], dp[1][i] &= f[i]; if(x == 'S') for(int i=2; i<=n; ++i) dp[1][i] |= dp[0][i-1], dp[1][i] &= f[i]; if(x == 'W') for(int i=1; i<=n; ++i) dp[1][i] |= (dp[0][i]>>1), dp[1][i] &= f[i]; if(x == 'E') for(int i=1; i<=n; ++i) dp[1][i] |= (dp[0][i]<<1), dp[1][i] &= f[i]; if(x == '?'){ for(int i=n-1; i; --i) dp[1][i] |= dp[0][i+1], dp[1][i] &= f[i]; for(int i=2; i<=n; ++i) dp[1][i] |= dp[0][i-1], dp[1][i] &= f[i]; for(int i=1; i<=n; ++i) dp[1][i] |= (dp[0][i]>>1), dp[1][i] &= f[i]; for(int i=1; i<=n; ++i) dp[1][i] |= (dp[0][i]<<1), dp[1][i] &= f[i]; } for(int i=1; i<=n; ++i) dp[0][i] = dp[1][i], dp[1][i].reset(); } int Ans = 0; for(int i=1; i<=n; ++i) Ans += dp[0][i].count(); cout << Ans; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define NAME "TAUCHIEN" if(fopen(NAME".inp", "r")){ freopen(NAME".inp", "r", stdin); freopen(NAME".out", "w", stdout); } Solve(); return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         freopen(NAME".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:50:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |         freopen(NAME".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...