| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1282628 | quan606303 | Nautilus (BOI19_nautilus) | C++20 | 1 ms | 332 KiB |
/*
* @Author: RMQuan
* @Date: 2025-09-08 15:49:18
* @Last Modified by: RMQuan
* @Last Modified time: 2025-10-23 22:21:18
*/
/*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);
file("TEST");
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]=='?') && j+1<=n) dp[i&1][j] |= dp[(i-1)&1][j+1];
if ((s[i]=='S'||s[i]=='?') && j-1>=1) 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;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
