Submission #442929

#TimeUsernameProblemLanguageResultExecution timeMemory
442929baoduytran0104Patkice (COCI20_patkice)C++17
50 / 50
1 ms332 KiB
#include <iostream> using namespace std; char a[105][105]; int m, n, u, v, res; bool check; void f(int x, int y) { ++res; if(a[x][y] == '.') return; if(a[x][y] == 'x') {check = 1; return;} if(a[x][y] == 'v') f(x + 1, y); if(a[x][y] == '^') f(x - 1, y); if(a[x][y] == '<') f(x, y - 1); if(a[x][y] == '>') f(x, y + 1); } int main() { ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr); cin >> m >> n; for(int i = 1; i <= m; ++i) { for(int j = 1; j <= n; ++j) { cin >> a[i][j]; if(a[i][j] == 'o') { u = i; v = j; } } } res = 0; int ans = 1e9; char k = 'a'; f(u, v + 1); if(check && ans > res) {ans = res; k = 'E';} res = 0; check = 0; f(u - 1, v); if(check && ans > res) {ans = res; k = 'N';} res = 0; check = 0; f(u + 1, v); if(check && ans > res) {ans = res; k = 'S';} res = 0; check = 0; f(u, v - 1); if(check && ans > res) {ans = res; k = 'W';} if(ans == 1e9) cout << ":("; else cout << ":)" << '\n' << k; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...