Submission #486308

#TimeUsernameProblemLanguageResultExecution timeMemory
486308Christopher_Patkice (COCI20_patkice)C++17
0 / 50
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; int n, m; cin >> n >> m; vector<string> g(n); pair<int, int> st, fi; vector<vector<bool>> vis(n, vector<bool>(m)); for (int i = 0; i < n; ++i) { cin >> g[i]; for (int j = 0; j < m; ++j) { if (g[i][j] == 'o') { st = {i, j}; } else if (g[i][j] == 'x') { fi = {i, j}; } } } auto e = [&](int x, int y) { if (x >= 0 && x < n && y >= 0 && y < m && !vis[x][y] && g[x][y] != '.') return true; return false; }; int x, y; x = st.first, y = st.second; x++; while (x != fi.first || y != fi.second) { if (!e(x, y)) { break; } vis[x][y] = true; if (g[x][y] == '^') { x--; } else if (g[x][y] == 'v') { x++; } else if (g[x][y] == '>') { y++; } else { --y; } } if (x == fi.first && y == fi.second) { return cout << ":)" << '\n' << "S" << '\n', 0; } x = st.first, y = st.second; x--; while (x != fi.first || y != fi.second) { if (!e(x, y)) { break; } vis[x][y] = true; if (g[x][y] == '^') { x--; } else if (g[x][y] == 'v') { x++; } else if (g[x][y] == '>') { y++; } else { --y; } } if (x == fi.first && y == fi.second) { return cout << ":)" << '\n' << "N" << '\n', 0; } x = st.first, y = st.second; y++; while (x != fi.first || y != fi.second) { if (!e(x, y)) { break; } vis[x][y] = true; if (g[x][y] == '^') { x--; } else if (g[x][y] == 'v') { x++; } else if (g[x][y] == '>') { y++; } else { --y; } } if (x == fi.first && y == fi.second) { return cout << ":)" << '\n' << "R" << '\n', 0; } x = st.first, y = st.second; y--; while (x != fi.first || y != fi.second) { if (!e(x, y)) { break; } vis[x][y] = true; if (g[x][y] == '^') { x--; } else if (g[x][y] == 'v') { x++; } else if (g[x][y] == '>') { y++; } else { --y; } } if (x == fi.first && y == fi.second) { return cout << ":)" << '\n' << "L" << '\n', 0; } cout << ":(" << '\n'; }

Compilation message (stderr)

patkice.cpp: In function 'int main()':
patkice.cpp:8:12: warning: unused variable 'dx' [-Wunused-variable]
    8 |  const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
      |            ^~
patkice.cpp:8:35: warning: unused variable 'dy' [-Wunused-variable]
    8 |  const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
      |                                   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...