# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1191646 | SmuggingSpun | Patkice (COCI20_patkice) | C++20 | 1095 ms | 328 KiB |
#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
const int lim = 105;
const int INF = 1e9;
char d = '#', a[lim][lim];
int n, m, min_time = INF;
void move(int i, int j, int t, const char ans){
if(t >= min_time){
return;
}
if(a[i][j] == 'x'){
min_time = t;
d = ans;
return;
}
if(a[i][j] == '^'){
move(i - 1, j, t + 1, ans);
}
else if(a[i][j] == 'v'){
move(i + 1, j, t + 1, ans);
}
else if(a[i][j] == '<'){
move(i, j - 1, t + 1, ans);
}
else{
move(i, j + 1, t + 1, ans);
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> a[i][j];
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(a[i][j] == 'o'){
move(i, j + 1, 0, 'E');
move(i - 1, j, 0, 'N');
move(i + 1, j, 0, 'S');
move(i, j - 1, 0, 'W');
if(d == '#'){
return cout << ":(", 0;
}
return cout << ":)\n" << d, 0;
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |