Submission #712014

#TimeUsernameProblemLanguageResultExecution timeMemory
712014LoboNautilus (BOI19_nautilus)C++17
100 / 100
162 ms704 KiB
#include<bits/stdc++.h> using namespace std; const long long inf = (long long) 1e18 + 10; const int inf1 = (int) 1e9 + 10; #define dbl long double #define endl '\n' #define sc second #define fr first #define mp make_pair #define pb push_back #define all(x) x.begin(), x.end() const int maxn = 550; int r,c,m; bitset<maxn> dp[2][maxn], a[maxn]; vector<pair<int,int>> adj = {mp(0,-1),mp(0,1),mp(1,0),mp(-1,0)}; void solve() { cin >> r >> c >> m; for(int i = 0; i < r; i++) { string s; cin >> s; for(int j = 0; j < c; j++) { if(s[j] == '.') a[i+1][j+1] = 1; } } string s; cin >> s; for(int i = 1; i <= r; i++) { for(int j = 1; j <= c; j++) { dp[0][i][j] = a[i][j]; } } for(int k = 1; k <= m; k++) { for(int i = 1; i <= r; i++) { if(s[k-1] == '?') { dp[k&1][i] = a[i]&((dp[k&1^1][i]>>1)|(dp[k&1^1][i]<<1)|(dp[k&1^1][i-1])|(dp[k&1^1][i+1])); } else { if(s[k-1] == 'S') dp[k&1][i] = a[i]&dp[k&1^1][i-1]; if(s[k-1] == 'N') dp[k&1][i] = a[i]&dp[k&1^1][i+1]; if(s[k-1] == 'W') dp[k&1][i] = a[i]&(dp[k&1^1][i]>>1); if(s[k-1] == 'E') dp[k&1][i] = a[i]&(dp[k&1^1][i]<<1); } } } int ans = 0; for(int i = 1; i <= r; i++) { for(int j = 1; j <= c; j++) { ans+= dp[m&1][i][j]; } } cout << ans << endl; } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); // freopen("in.in", "r", stdin); // freopen("out.out", "w", stdout); int tt = 1; // cin >> tt; while(tt--) { solve(); } }

Compilation message (stderr)

nautilus.cpp: In function 'void solve()':
nautilus.cpp:38:41: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   38 |                 dp[k&1][i] = a[i]&((dp[k&1^1][i]>>1)|(dp[k&1^1][i]<<1)|(dp[k&1^1][i-1])|(dp[k&1^1][i+1]));
      |                                        ~^~
nautilus.cpp:38:59: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   38 |                 dp[k&1][i] = a[i]&((dp[k&1^1][i]>>1)|(dp[k&1^1][i]<<1)|(dp[k&1^1][i-1])|(dp[k&1^1][i+1]));
      |                                                          ~^~
nautilus.cpp:38:77: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   38 |                 dp[k&1][i] = a[i]&((dp[k&1^1][i]>>1)|(dp[k&1^1][i]<<1)|(dp[k&1^1][i-1])|(dp[k&1^1][i+1]));
      |                                                                            ~^~
nautilus.cpp:38:94: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   38 |                 dp[k&1][i] = a[i]&((dp[k&1^1][i]>>1)|(dp[k&1^1][i]<<1)|(dp[k&1^1][i-1])|(dp[k&1^1][i+1]));
      |                                                                                             ~^~
nautilus.cpp:41:57: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   41 |                 if(s[k-1] == 'S') dp[k&1][i] = a[i]&dp[k&1^1][i-1];
      |                                                        ~^~
nautilus.cpp:42:57: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   42 |                 if(s[k-1] == 'N') dp[k&1][i] = a[i]&dp[k&1^1][i+1];
      |                                                        ~^~
nautilus.cpp:43:58: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   43 |                 if(s[k-1] == 'W') dp[k&1][i] = a[i]&(dp[k&1^1][i]>>1);
      |                                                         ~^~
nautilus.cpp:44:58: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   44 |                 if(s[k-1] == 'E') dp[k&1][i] = a[i]&(dp[k&1^1][i]<<1);
      |                                                         ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...