제출 #359919

#제출 시각아이디문제언어결과실행 시간메모리
359919MrRobot_28Patkice (COCI20_patkice)C++17
0 / 50
1043 ms492 KiB
#include<bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; char A[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; } } } vector <int> dx, dy; vector <char> vec; dx = {0, -1, 1, 0}; dy = {1, 0, 0, -1}; vec = {'E', 'N', 'S', 'W'}; vector <char> vec1; vec1 = {'>', '^', 'v', '<'}; char p1 = ' '; int ans = 1e9; for(int i = 0; i < 4; i++) { pair <int, int> st = {stx + dx[i], sty + dy[i]}; bool fl = 0; int cnt = 0; while(true) { cnt++; if(st.first < 0 || st.second < 0 || st.first >= n || st.second >= m) { break; } if(A[st.first][st.second] == 'x') { fl = 1; break; } if(A[st.first][st.second] == '.') { break; } for(int j = 0; j < 4; j++) { if(A[st.first][st.second] == vec1[j]) { st.first += dx[j]; st.second += dy[j]; break; } } } // cout << st.first << " " << st.second << "\n"; if(fl && cnt < ans) { ans = cnt; p1 = vec[i]; } } if(p1 == ' ') { cout << ":("; } else { cout << ":)\n"; cout << p1; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

patkice.cpp: In function 'int main()':
patkice.cpp:35:35: warning: 'stx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |         pair <int, int> st = {stx + dx[i], sty + dy[i]};
patkice.cpp:35:48: warning: 'sty' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |         pair <int, int> st = {stx + dx[i], sty + dy[i]};
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...