# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
436078 | peace | Patkice (COCI20_patkice) | C++17 | 1 ms | 332 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 <bits/stdc++.h>
using namespace std;
const int N = 105;
const int SZ = N * N;
const int hi[] = {0, -1, 1, 0};
const int hj[] = {1, 0, 0, -1};
const char *cv = "ENSW";
char s[N];
int c[N][N];
int main() {
map<char,int> mp;
mp['>'] = 0;
mp['^'] = 1;
mp['v'] = 2;
mp['<'] = 3;
mp['o'] = -1;
mp['x'] = -2;
mp['.'] = -3;
int n, m;
scanf("%d%d", &n, &m);
int src_i, src_j;
for (int i = 0; i < n; i++) {
scanf("%s", s);
for (int j = 0; j < m; j++) {
c[i][j] = mp[s[j]];
if (c[i][j] == -1) {
src_i = i;
src_j = j;
}
}
}
int res = -1;
char res_c;
for (int dr = 0; dr < 4; dr++) {
int i = src_i;
int j = src_j;
int sz = 0;
i += hi[dr];
j += hj[dr];
sz++;
while (c[i][j] >= 0) {
int val = c[i][j];
i += hi[val];
j += hj[val];
sz++;
}
if (c[i][j] != -2) continue;
if (res < 0 || res > sz) {
res = sz;
res_c = cv[dr];
}
}
if (res < 0) puts(":(");
else {
puts(":)");
printf("%c\n", res_c);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |