Submission #443579

#TimeUsernameProblemLanguageResultExecution timeMemory
443579JovanBNautilus (BOI19_nautilus)C++17
100 / 100
51 ms420 KiB
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; bitset <500> dpp[505]; bitset <500> dp[505]; bitset <500> rows[505]; int main(){ ios_base::sync_with_stdio(false), cin.tie(0); cout.precision(10); cout << fixed; int n, m, k; cin >> n >> m >> k; for(int i=1; i<=n; i++){ string s; cin >> s; for(int j=0; j<m; j++){ if(s[j] == '.') dp[i][j] = rows[i][j] = 1; } } while(k--){ for(int i=1; i<=n; i++) dpp[i] = dp[i]; char c; cin >> c; if(c == 'W'){ for(int i=1; i<=n; i++) dp[i] = (dpp[i] >> 1); } else if(c == 'E'){ for(int i=1; i<=n; i++) dp[i] = (dpp[i] << 1); } else if(c == 'N'){ for(int i=1; i<=n; i++) dp[i] = dpp[i+1]; } else if(c == 'S'){ for(int i=1; i<=n; i++) dp[i] = dpp[i-1]; } else{ for(int i=1; i<=n; i++){ dp[i] = (dpp[i] << 1); dp[i] |= (dpp[i] >> 1); dp[i] |= dpp[i+1]; dp[i] |= dpp[i-1]; } } for(int i=1; i<=n; i++) dp[i] &= rows[i]; } int res = 0; for(int i=1; i<=n; i++){ res += dp[i].count(); } cout << res << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...