답안 #426899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426899 2021-06-14T10:46:39 Z schse Nautilus (BOI19_nautilus) C++17
0 / 100
3 ms 304 KB
#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

nautilus.cpp: In function 'bool dfs(int, int, int)':
nautilus.cpp:12:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     if (n == dirs.size())
      |         ~~^~~~~~~~~~~~~~
nautilus.cpp: In function 'int main()':
nautilus.cpp:33:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int e = 0; e < str.size(); e++)
      |                         ~~^~~~~~~~~~~~
nautilus.cpp: In function 'bool dfs(int, int, int)':
nautilus.cpp:22:1: warning: control reaches end of non-void function [-Wreturn-type]
   22 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -