#include <bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {-1, 0, 1, 0};
const char CH[5] = "WNES";
const int maxn = 105;
int n, m;
int dis[maxn][maxn];
char s[maxn][maxn];
vector<pair<int, char> > vec;
int main(){
//freopen("patkice.in", "r", stdin);
scanf("%d%d", &n, &m);
for(int i = 0; i < n; ++i)
scanf("%s", s[i]);
for(int i = 0; i < n; ++i)
for(int j = 0; j < m; ++j)
if(s[i][j] == 'o'){
for(int k = 0; k < 4; ++k){
memset(dis, -1, sizeof(dis));
dis[i][j] = 0; int cur = 1, x, y;
for(x = i + dx[k], y = j + dy[k]; x >= 0 && x < n && y >= 0 && y < m && !~dis[x][y] && s[x][y] != '.' && s[x][y] != 'x'; ++cur){
dis[x][y] = cur;
if(s[x][y] == '<')
--y;
else if(s[x][y] == '>')
++y;
else if(s[x][y] == '^')
--x;
else
++x;
}
if(s[x][y] == 'x')
vec.PB(MP(cur, CH[k]));
}
}
sort(vec.begin(), vec.end());
if(!vec.size())
puts(":(");
else
puts(":)"), putchar(vec[0].snd);
return 0;
}
Compilation message
patkice.cpp: In function 'int main()':
patkice.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
patkice.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
25 | scanf("%s", s[i]);
| ~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
0 ms |
332 KB |
Output is correct |
17 |
Correct |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |