Submission #712645

#TimeUsernameProblemLanguageResultExecution timeMemory
712645TimDeeNautilus (BOI19_nautilus)C++17
100 / 100
20 ms956 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("avx2,popcnt") //#define int long long //#define int int16_t #define forn(i,n) for(size_t i=0;i<n;++i) #define pb push_back #define all(x) x.begin(),x.end() #define pi pair<int,int> #define f first #define s second const int N=502, M=502; bitset<M> dp[2][N]; bitset<M> ok[N]; void solve() { int n,m,k; cin>>n>>m>>k; vector<string> a(n); forn(i,n) cin>>a[i]; string s; cin>>s; forn(i,n) forn(j,m) if (a[i][j]=='.') dp[0][i+1].set(j+1), ok[i+1].set(j+1); bool u,d,l,r,t; forn(it,k) { char c=s[it]; int b=it&1; for (int i=1; i<=n; ++i) { if (c=='?') { dp[b^1][i]=ok[i]&((dp[b][i]>>1)|(dp[b][i]<<1)|dp[b][i+1]|dp[b][i-1]); } else { if (c=='N') dp[b^1][i]=ok[i]&dp[b][i+1]; if (c=='S') dp[b^1][i]=ok[i]&dp[b][i-1]; if (c=='W') dp[b^1][i]=ok[i]&(dp[b][i]>>1); if (c=='E') dp[b^1][i]=ok[i]&(dp[b][i]<<1); } } } int32_t ans=0; forn(i,n) forn(j,m) ans+=dp[k&1][i+1][j+1]; cout<<ans; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; //cin >> t; while (t--) solve(); return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'void solve()':
nautilus.cpp:10:35: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 | #define forn(i,n) for(size_t i=0;i<n;++i)
......
   26 |  forn(i,n) cin>>a[i];
      |       ~~~                          
nautilus.cpp:26:2: note: in expansion of macro 'forn'
   26 |  forn(i,n) cin>>a[i];
      |  ^~~~
nautilus.cpp:10:35: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 | #define forn(i,n) for(size_t i=0;i<n;++i)
......
   28 |  forn(i,n) forn(j,m) if (a[i][j]=='.') dp[0][i+1].set(j+1), ok[i+1].set(j+1);
      |       ~~~                          
nautilus.cpp:28:2: note: in expansion of macro 'forn'
   28 |  forn(i,n) forn(j,m) if (a[i][j]=='.') dp[0][i+1].set(j+1), ok[i+1].set(j+1);
      |  ^~~~
nautilus.cpp:10:35: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 | #define forn(i,n) for(size_t i=0;i<n;++i)
......
   28 |  forn(i,n) forn(j,m) if (a[i][j]=='.') dp[0][i+1].set(j+1), ok[i+1].set(j+1);
      |                 ~~~                
nautilus.cpp:28:12: note: in expansion of macro 'forn'
   28 |  forn(i,n) forn(j,m) if (a[i][j]=='.') dp[0][i+1].set(j+1), ok[i+1].set(j+1);
      |            ^~~~
nautilus.cpp:10:35: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 | #define forn(i,n) for(size_t i=0;i<n;++i)
......
   31 |  forn(it,k) {
      |       ~~~~                         
nautilus.cpp:31:2: note: in expansion of macro 'forn'
   31 |  forn(it,k) {
      |  ^~~~
nautilus.cpp:10:35: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 | #define forn(i,n) for(size_t i=0;i<n;++i)
......
   48 |  forn(i,n) forn(j,m) ans+=dp[k&1][i+1][j+1];
      |       ~~~                          
nautilus.cpp:48:2: note: in expansion of macro 'forn'
   48 |  forn(i,n) forn(j,m) ans+=dp[k&1][i+1][j+1];
      |  ^~~~
nautilus.cpp:10:35: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 | #define forn(i,n) for(size_t i=0;i<n;++i)
......
   48 |  forn(i,n) forn(j,m) ans+=dp[k&1][i+1][j+1];
      |                 ~~~                
nautilus.cpp:48:12: note: in expansion of macro 'forn'
   48 |  forn(i,n) forn(j,m) ans+=dp[k&1][i+1][j+1];
      |            ^~~~
nautilus.cpp:30:7: warning: unused variable 'u' [-Wunused-variable]
   30 |  bool u,d,l,r,t;
      |       ^
nautilus.cpp:30:9: warning: unused variable 'd' [-Wunused-variable]
   30 |  bool u,d,l,r,t;
      |         ^
nautilus.cpp:30:11: warning: unused variable 'l' [-Wunused-variable]
   30 |  bool u,d,l,r,t;
      |           ^
nautilus.cpp:30:13: warning: unused variable 'r' [-Wunused-variable]
   30 |  bool u,d,l,r,t;
      |             ^
nautilus.cpp:30:15: warning: unused variable 't' [-Wunused-variable]
   30 |  bool u,d,l,r,t;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...