Submission #1105574

#TimeUsernameProblemLanguageResultExecution timeMemory
1105574coolboy19521Patkice (COCI20_patkice)C++17
0 / 50
1 ms660 KiB
#include "bits/stdc++.h" using namespace std; int main() { int r, m; cin >> r >> m; vector<vector<char>> gr(r, vector<char>(m)); int a, b; int c, d; for (int i = 0; i < r; i ++) { for (int j = 0; j < m; j ++) { cin >> gr[i][j]; if ('o' == gr[i][j]) { a = i; b = j; } if ('x' == gr[i][j]) { c = i; d = j; } } } int maxr = r * m + 1; int an = maxr; char sy = 'Z'; function<void(int,int,int,char)> dfs; dfs = [&](int y, int x, int s, char l){ if (y == c && x == d) { if (s < an) { an = s; sy = l; } else if (s == an) { sy = min(sy, l); } } else if ('>' == gr[y][x]) { // cout << "a haver\n"; dfs(y, x + 1, s + 1, l); } else if ('<' == gr[y][x]) { // cout << "hola\n"; dfs(y, x - 1, s + 1, l); } else if ('v' == gr[y][x]) { // cout << "hey\n"; dfs(y + 1, x, s + 1, l); } else if ('^' == gr[y][x]) { // cout << "hi\n"; dfs(y - 1, x, s + 1, l); } }; if (0 < a) { dfs(a, b - 1, 1, 'W'); } if (a + 1 < m) { dfs(a, b + 1, 1, 'E'); } if (0 < b) { dfs(a - 1, b, 1, 'N'); } if (b + 1 < r) { dfs(a + 1, b, 1, 'S'); } if (maxr != an) { cout << ":)\n" << sy << '\n'; } else { cout << ":(\n"; } }

Compilation message (stderr)

patkice.cpp: In function 'int main()':
patkice.cpp:65:12: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   65 |         dfs(a - 1, b, 1, 'N');
      |         ~~~^~~~~~~~~~~~~~~~~~
patkice.cpp:59:12: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |         dfs(a, b - 1, 1, 'W');
      |         ~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...