# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1111317 | hainam2k9 | Nautilus (BOI19_nautilus) | C++17 | 144 ms | 158888 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
using namespace std;
const int MOD = 1e9+7, MAXN = 1e5+5;
const string NAME = "";
int n,m,k,rs=0;
bitset<505> dp[5005][505],mask[505];
char c;
int main()
{
tt;
if(fopen((NAME + ".INP").c_str(), "r")) fo;
cin >> n >> m >> k;
for(int i = 1; i<=n; ++i)
for(int j = 1; j<=m; ++j){
cin >> c;
if(c=='.') dp[0][i][j]=1, mask[i][j]=1;
}
for(int i = 1; i<=k; ++i){
cin >> c;
for(int j = 1; j<=n; ++j){
if(c=='N'||c=='?') dp[i][j]|=dp[i-1][j+1];
if(c=='S'||c=='?') dp[i][j]|=dp[i-1][j-1];
if(c=='W'||c=='?') dp[i][j]|=dp[i-1][j]>>1;
if(c=='E'||c=='?') dp[i][j]|=dp[i-1][j]<<1;
dp[i][j]&=mask[j];
}
}
for(int i = 1; i<=n; ++i) rs+=dp[k][i].count();
cout << rs;
}
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... |