Submission #484923

#TimeUsernameProblemLanguageResultExecution timeMemory
484923Kirill22Patkice (COCI20_patkice)C++17
50 / 50
1 ms332 KiB
#include<bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define pii pair<int, int> #define fi first #define se second const int N = 100; char a[N][N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; int stx, sty; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; if (a[i][j] == 'o') stx = i, sty = j; } } pair<int, char> ans = {(int) 1e9, 'A'}; for (auto c : "SENW") { int x = stx, y = sty, dist = 0; if (c == 'N') x--; if (c == 'E') y++; if (c == 'W') y--; if (c == 'S') x++; while (x >= 0 && x < n && y >= 0 && y < m) { dist++; if (a[x][y] == '>') y++; else if (a[x][y] == '<') y--; else if (a[x][y] == '^') x--; else if (a[x][y] == 'v') x++; else break; } //cout << dist << " " << c << endl; if (x >= 0 && x < n && y >= 0 && y < m && a[x][y] == 'x') { ans = min(ans, {dist, c}); } } if (ans.se != 'A') { cout << ":)\n" << ans.se; } else { cout << ":("; } }

Compilation message (stderr)

patkice.cpp: In function 'int main()':
patkice.cpp:31:24: warning: 'sty' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |         if (c == 'W') y--;
      |                       ~^~
patkice.cpp:32:24: warning: 'stx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |         if (c == 'S') x++;
      |                       ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...