Submission #530140

#TimeUsernameProblemLanguageResultExecution timeMemory
530140c28dnv9q3Nautilus (BOI19_nautilus)C++17
29 / 100
1088 ms384 KiB
#include <iostream> using namespace std; const int MAX = 505; int r, c, m; bool grid[MAX][MAX], position[MAX][MAX]; string input; void solve(int x, int y, int i) { if (x < 0 || x >= c || y < 0 || y >= r || !grid[y][x]) { return; } if (i == input.length()) { position[y][x] = true; return; } switch (input[i]) { case 'N': solve(x, y - 1, i + 1); break; case 'E': solve(x + 1, y, i + 1); break; case 'S': solve(x, y + 1, i + 1); break; case 'W': solve(x - 1, y, i + 1); break; case '?': solve(x, y - 1, i + 1); solve(x + 1, y, i + 1); solve(x, y + 1, i + 1); solve(x - 1, y, i + 1); break; } } int main() { cin >> r >> c >> m; for (int i = 0; i < r; ++i) { string s; cin >> s; for (int j = 0; j < c; ++j) { grid[i][j] = (s[j] == '.'); } } cin >> input; for (int i = 0; i < r; ++i) { for (int j = 0; j < c; ++j) { solve(j, i, 0); } } int result = 0; for (int i = 0; i < r; ++i) { for (int j = 0; j < c; ++j) { result += position[i][j]; } } cout << result; }

Compilation message (stderr)

nautilus.cpp: In function 'void solve(int, int, int)':
nautilus.cpp:15:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  if (i == input.length()) {
      |      ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...