# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
956032 | n3rm1n | Nautilus (BOI19_nautilus) | C++17 | 8 ms | 10076 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 endl '\n'
using namespace std;
const int MAXN = 105;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, m, t;
int a[MAXN][MAXN];
string operations;
void read()
{
cin >> n >> m >> t;
char s;
for (int i = 1; i <= n; ++ i)
{
for (int j = 1; j <= m; ++ j)
{
cin >> s;
if(s == '#')a[i][j] = 1;
}
}
cin >> operations;
operations = '+' + operations;
}
int dp[MAXN][MAXN][MAXN];
void solve()
{
for (int i = 1; i <= n; ++ i)
{
for (int j = 1; j <= m; ++ j)
{
if(!a[i][j])dp[i][j][0] = 1;
}
}
for (int op = 1; op < operations.size(); ++ op)
{
for (int i = 1; i <= n; ++ i)
{
for (int j = 1; j <= m; ++ j)
{
if(a[i][j])continue;
if(!dp[i][j][op-1])continue;
if(operations[op] == 'N' || operations[op] == '?')
{
dp[i-1][j][op] = 1;
}
if(operations[op] == 'S' || operations[op] == '?')
{
dp[i+1][j][op] = 1;
}
if(operations[op] == 'E' || operations[op] == '?')
{
dp[i][j+1][op] = 1;
}
if(operations[op] == 'W' || operations[op] == '?')
{
dp[i][j-1][op] = 1;
}
}
}
}
int ans = 0;
for (int i = 1; i <= n; ++ i)
{
for (int j = 1; j <= m; ++ j)
if(!a[i][j] && dp[i][j][t])ans ++;
}
cout << ans << endl;
}
int main()
{
speed();
read();
solve();
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... |