# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
413557 | 2021-05-28T22:26:54 Z | nemethm | Patkice (COCI20_patkice) | C++17 | 1000 ms | 204 KB |
#include <iostream> #include <list> #include <algorithm> #include <queue> #include <vector> #include <limits> #include <set> #include <numeric> #include <string> #include <assert.h> #include <map> #include <cmath> #include <stack> #include <cstring> #pragma warning(disable : 4996) using namespace std; using ll = long long int; const ll inf = 1e10; const ll mod = 998244353; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } char t[110][110]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; pair<int, int> start; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> t[i][j]; if (t[i][j] == 'o') start = { i,j }; } } pair<char, int> out = { -1,numeric_limits<int>::max() }; char c[4] = { 'S', 'N', 'E', 'W' }; pair<int, int> dir[4] = { {1,0},{-1,0}, {0,1}, {0,-1} }; for (int i = 0; i < 4; ++i) { pair<int, int> p = { start.first + dir[i].first, start.second + dir[i].second }; int l = 1; while (t[p.first][p.second] != '.' && t[p.first][p.second] != 'x') { switch (t[p.first][p.second]) { case '>': ++p.second; break; case '<': --p.second; break; case '^': --p.first; break; case 'v': ++p.first; break; default: break; } ++l; } if (t[p.first][p.second] == 'x') { if (l == out.second && c[i] < out.first) out.first = c[i]; if (l < out.second) out = { c[i], l }; } } if (out.first == -1) cout << ":(" << endl; else { cout << ":)\n" << out.first << endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1090 ms | 204 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1085 ms | 204 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |