Submission #851365

#TimeUsernameProblemLanguageResultExecution timeMemory
851365vjudge1Patkice (COCI20_patkice)C++17
50 / 50
1 ms444 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast,O3,unroll-loops") #define int long long #define vi vector<int> #define vvi vector<vi> #define pii pair<int, int> #define vpi vector<pii> #define vvpi vector<vpi> #define vb vector<bool> #define vvb vector<vb> #define endl "\n" #define sp << " " << #define F(i, s, n) for(int i = s; i < n; i++) #define pb push_back #define fi first #define se second int inf = LLONG_MAX >> 3; int n, m; string grid[100]; int floodfill(int y, int x, int d = 0) { if(x < 0 || y < 0 || x >= m || y >= n || grid[y][x] == '.') return inf; if(grid[y][x] == 'x') { return d; } if(grid[y][x] == '^') return floodfill(y-1, x, d+1); if(grid[y][x] == 'v') return floodfill(y+1, x, d+1); if(grid[y][x] == '<') return floodfill(y, x-1, d+1); if(grid[y][x] == '>') return floodfill(y, x+1, d+1); return inf; } void solve() { cin >> n >> m; F(i, 0, n) cin >> grid[i]; int y, x; F(i, 0, n) { F(j, 0, m) { if(grid[i][j] == 'o') { y = i; x = j; break; } } } string ans = ""; int mn = inf; int r; r = floodfill(y, x+1); if(r < mn) {ans = "E"; mn = r;} r = floodfill(y-1, x); if(r < mn) {ans = "N"; mn = r;} r = floodfill(y+1, x); if(r < mn) {ans = "S"; mn = r;} r = floodfill(y, x-1); if(r < mn) {ans = "W"; mn = r;} if(ans.length() > 0) cout << ":)\n" << ans << endl; else cout << ":(" << endl; } void setIO() { ios::sync_with_stdio(0); cin.tie(0); #ifdef Local freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif } signed main() { setIO(); solve(); }

Compilation message (stderr)

patkice.cpp: In function 'void solve()':
patkice.cpp:54:18: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |     r = floodfill(y, x+1); if(r < mn) {ans = "E"; mn = r;}
      |         ~~~~~~~~~^~~~~~~~
patkice.cpp:54:18: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...