# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
413556 | nemethm | Patkice (COCI20_patkice) | C++17 | 1092 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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[100][100];
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |