Submission #464367

#TimeUsernameProblemLanguageResultExecution timeMemory
464367dannyboy20031204Patkice (COCI20_patkice)C++17
0 / 50
1094 ms204 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define double long double using namespace std; void db() {cerr << endl;} template <typename T, typename ...U> void db(T a, U ...b) { cerr << a << ' ', db(b...); } const int N = 100, inf = 1e9 + 1; int n, m; string a[N]; int solve(int x, int y){ int ans = 1; while (a[x][y] != 'x'){ ans++; if (a[x][y] == '.') return inf; else if (a[x][y] == '^') x--; else if (a[x][y] == 'v') x++; else if (a[x][y] == '<') y--; else y++; } return ans; } int main(){ ios::sync_with_stdio(0), cin.tie(0); cin >> n >> m; int x, y; for (int i = 0; i < n; i++){ cin >> a[i]; for (int j = 0; j < m; j++) if (a[i][j] == 'o') x = i, y = j; } int ans = solve(x, y + 1); char d = 'E'; if (ans > solve(x - 1, y)) ans = solve(x - 1, y), d = 'N'; if (ans > solve(x + 1, y)) ans = solve(x + 1, y), d = 'S'; if (ans > solve(x, y - 1)) ans = solve(x, y - 1), d = 'W'; if (ans == inf){ cout << ":("; } else{ cout << ":)\n"; cout << d; } }

Compilation message (stderr)

patkice.cpp: In function 'int main()':
patkice.cpp:43:20: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |     if (ans > solve(x - 1, y))
      |               ~~~~~^~~~~~~~~~
patkice.cpp:43:20: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...