# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
426899 | schse | Nautilus (BOI19_nautilus) | C++17 | 3 ms | 304 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>
using namespace std;
bool dp[100][102][102];
string dirs;
vector<vector<bool>> field;
bool dfs(int n, int x, int y)
{
if (!field[y][x])
return false;
if (n == dirs.size())
return true;
if (dirs[n] == 'N')
return dfs(n + 1, x, y - 1);
if (dirs[n] == 'S')
return dfs(n + 1, x, y + 1);
if (dirs[n] == 'W')
return dfs(n + 1, x - 1, y);
if (dirs[n] == 'E')
return dfs(n + 1, x - 1, y);
}
int main()
{
int R, C, M;
cin >> R >> C >> M;
field.resize(R + 2, vector<bool>(C + 2, 0));
for (int i = 0; i < R; i++)
{
string str;
cin >> str;
for (int e = 0; e < str.size(); e++)
field[i + 1][e+1] = str[e] == '.';
}
cin >> dirs;
int sum = 0;
for (int x = 0; x < C; x++)
{
for (int y = 0; y < R; y++)
{
if (dfs(0, x + 1, y + 1))
sum++;
}
}
cout << sum;
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... |