Submission #920729

#TimeUsernameProblemLanguageResultExecution timeMemory
920729blackavarPatkice (COCI20_patkice)C++14
30 / 50
2 ms2408 KiB
#include <bits/stdc++.h> using namespace std; long long h[7] = {0, 1, 0, -1, 0}; long long mark[1005][1005]; char pre[1005][1005]; bool valid(long long i, char c) { if (i == 0 && c == '>') return true; if (i == 1 && c == 'v') return true; if (i == 2 && c == '<') return true; if (i == 3 && c == '^') return true; return false; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long r, s; cin >> r >> s; char a[r + 1][s + 1]; for (int i = 1; i <= r; i++) { for (int j = 1; j <= s; j++) { cin >> a[i][j]; } } deque <pair<long long, long long>> dq; for (int i = 1; i <= r; i++) { for (int j = 1; j <= s; j++) { if (a[i][j] == 'o') { dq.push_back(make_pair(i, j)); mark[i][j] = 1; } } } bool check = false; while (!dq.empty()) { pair <long long, long long> u = dq.front(); dq.pop_front(); if (a[u.first][u.second] == 'x') { check = true; break; } for (int i = 0; i <= 3; i++) { long long newx = u.first + h[i], newy = u.second + h[i + 1]; if (!mark[newx][newy] && newx <= r && newy <= s && newx >= 1&& newy >= 1 && a[newx][newy] != '.') { if (a[u.first][u.second] == 'o') { if (i == 0) pre[newx][newy] = 'E'; if (i == 1) pre[newx][newy] = 'S'; if (i == 2) pre[newx][newy] = 'W'; if (i == 3) pre[newx][newy] = 'N'; dq.push_back(make_pair(newx, newy)); } else { if (valid(i, a[u.first][u.second])) { dq.push_back(make_pair(newx, newy)); mark[newx][newy] = 1; pre[newx][newy] = pre[u.first][u.second]; } } } } } long long posx, posy; for (int i = 1; i <= r; i++) { for (int j = 1; j <= s; j++) { if (a[i][j] == 'x') { posx = i; posy = j; break; } } } if (check) cout << ":)" << "\n" << pre[posx][posy] << "\n"; else cout << ":("; return 0; }

Compilation message (stderr)

patkice.cpp: In function 'int main()':
patkice.cpp:92:54: warning: 'posy' may be used uninitialized in this function [-Wmaybe-uninitialized]
   92 |     if (check) cout << ":)" << "\n" << pre[posx][posy] << "\n";
      |                                        ~~~~~~~~~~~~~~^
patkice.cpp:92:54: warning: 'posx' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...