Submission #1282630

#TimeUsernameProblemLanguageResultExecution timeMemory
1282630quan606303Nautilus (BOI19_nautilus)C++20
100 / 100
107 ms580 KiB
/* * @Author: RMQuan * @Date: 2025-09-08 15:49:18 * @Last Modified by: RMQuan * @Last Modified time: 2025-10-23 22:22:57 */ /*idea : */ #include <bits/stdc++.h> bool M1; #define int long long #define ll long long #define INTMAX INT_MAX #define INTMIN INT_MIN #define LONGMAX LLONG_MAX #define LONGMIN LLONG_MIN #define fi first #define se second #define memfull(a,b) memset(a,b,sizeof(a)); #define endl '\n' #define file(a) freopen(a".inp","r",stdin); freopen(a".out","w",stdout); using namespace std; const int MOD=1e9+7; const int maxn=505; bitset<maxn> a[maxn]; bitset<maxn> dp[2][maxn]; int n,m,k; string s; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m>>k; for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) { char x; cin>>x; a[i][j]=(x=='.'?1:0); } } cin>>s; s="$"+s; for (int i=1;i<=n;i++)dp[0][i]=a[i]; for (int i=1;i<=k;i++) for (int j=1;j<=n;j++) { dp[i&1][j].reset(); if ((s[i]=='N'||s[i]=='?')) dp[i&1][j] |= dp[(i-1)&1][j+1]; if ((s[i]=='S'||s[i]=='?')) dp[i&1][j] |= dp[(i-1)&1][j-1]; if ((s[i]=='E'||s[i]=='?')) dp[i&1][j] |= (dp[(i-1)&1][j] << 1); if ((s[i]=='W'||s[i]=='?')) dp[i&1][j] |= (dp[(i-1)&1][j] >> 1); dp[i&1][j] &= a[j]; } int ans=0; for (int i=1;i<=n;i++)ans+=dp[k&1][i].count(); cout<<ans; bool M2; cerr<<"-------------------------------------------------"<<endl; cerr<<"Time : "<<clock()<<" ms"<<endl; cerr<<"Memory : "<<abs(&M2-&M1)/1024/1024<<" MB"<<endl; cerr<<"-------------------------------------------------"<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...