Submission #804511

#TimeUsernameProblemLanguageResultExecution timeMemory
804511tlnk07Patkice (COCI20_patkice)C++17
0 / 50
217 ms524288 KiB
#include<bits/stdc++.h> using namespace std; long long n, m, start, finish; string s; vector<int> vec[10001]; bool check = 0; char ans; void dfs(int x) { if(x == finish) check = 1; if(check) return; for(int c : vec[x]) { if(x == start) { if(c == start + n) ans = 'S'; else if(c == start + 1) ans = 'E'; else if(c == start - 1) ans = 'W'; else ans = 'N'; } dfs(c); if(check) return; } } int main() { cin >> n >> m; for(int i = 0; i < n; ++i) { cin >> s; for(int j = 0; j < m; ++j) { if(s[j] == 'o') { start = i * n + j + 1; if(i < n - 1) vec[i * n + j + 1].push_back(i * n + j + n + 1); if(j < m - 1) vec[i * n + j + 1].push_back(i * n + j + 2); if(j > 0) vec[i * n + j + 1].push_back(i * n + j); if(i > 0) vec[i * n + j + 1].push_back(i * n + j - n + 1); } else if(s[j] == 'x') finish = i * n + j + 1; else if(s[j] == 'v') vec[i * n + j + 1].push_back(i * n + j + n + 1); else if(s[j] == '>') vec[i * n + j + 1].push_back(i * n + j + 2); else if(s[j] == '<') vec[i * n + j + 1].push_back(i * n + j); else if(s[j] == '^') vec[i * n + j + 1].push_back(i * n + j - n + 1); } } dfs(start); if(check) cout << ":)\n" << ans; else cout << ":("; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...