Submission #1016055

#TimeUsernameProblemLanguageResultExecution timeMemory
1016055vjudge1Patkice (COCI20_patkice)C++17
50 / 50
1 ms444 KiB
#include <bits/stdc++.h> using namespace std; const int N = 105; int n, m, sx, sy, ex, ey; char mat[N][N]; int dfs(int x, int y, int d = 1){ if (x < 1 or y < 1 or x > n or y > m) return 1e9; if (mat[x][y] == 'x') return d; if (mat[x][y] == '.' or mat[x][y] == 'o') return 1e9; if (mat[x][y] == '>') return dfs(x, y + 1, d + 1); if (mat[x][y] == '<') return dfs(x, y - 1, d + 1); if (mat[x][y] == 'v') return dfs(x + 1, y, d + 1); if (mat[x][y] == '^') return dfs(x - 1, y, d + 1); } int main(){ // E N S W cin >> n >> m; for (int i = 1; i <= n; i ++){ for (int j = 1; j <= m; j ++){ cin >> mat[i][j]; if (mat[i][j] == 'o') sx = i, sy = j; if (mat[i][j] == 'x') ex = i, ey = j; } } vector<pair<int, char>> vec; vec.push_back({dfs(sx, sy + 1), 'E'}); vec.push_back({dfs(sx - 1, sy), 'N'}); vec.push_back({dfs(sx + 1, sy), 'S'}); vec.push_back({dfs(sx, sy - 1), 'W'}); sort(vec.begin(), vec.end()); if (vec[0].first != 1e9){ cout << ":)" << endl; cout << vec[0].second << endl; } else cout << ":(" << endl; }

Compilation message (stderr)

patkice.cpp: In function 'int dfs(int, int, int)':
patkice.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
   18 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...