//#include <bits/stdc++.h> C++11
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <time.h>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <stack>
#include <queue>
#include <climits>
#include <map>
#include <set>
#include<sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int r,s;
char sea[101][101];
//scanf("%d%d",&r,&s);
cin>>r>>s;
short X,Y;
X=0;
Y=0;
short x,y;
for(int i=0;i<r;i++){
for(int j=0;j<s;j++){
//scanf(" %c",&sea[i][j]);
cin>>sea[i][j];
if (sea[i][j]=='o'){
X=i;
Y=j;
}
}
}
x=X;
y=Y;
int coun=0;
x = X;
y = Y;
int mi=100000;
int last=-1;
x = X;
y = Y;
if (y + 1 < s)
{
x = X;
y = Y;
y = y + 1;
coun = 0;
while (1)
{
if (sea[x][y] == 'x')
{
if (mi > coun)
{
mi = coun;
last = 1;
}
break;
}
if (sea[x][y] == '.')
{
break;
}
if (sea[x][y] == '>')
{
y++;
coun++;
continue;
}
if (sea[x][y] == '<')
{
y--;
coun++;
continue;
}
if (sea[x][y] == '^')
{
x--;
coun++;
continue;
}
if (sea[x][y] == 'v')
{
x++;
coun++;
continue;
}
}
}
x = X;
y = Y;
if (x - 1 >= 0)
{
x = X;
y = Y;
x = x - 1;
coun = 0;
while (1)
{
if (sea[x][y] == 'x')
{
if (mi > coun)
{
mi = coun;
last = 2;
}
break;
}
if (sea[x][y] == '.')
{
break;
}
if (sea[x][y] == '>')
{
y++;
coun++;
continue;
}
if (sea[x][y] == '<')
{
y--;
coun++;
continue;
}
if (sea[x][y] == '^')
{
x--;
coun++;
continue;
}
if (sea[x][y] == 'v')
{
x++;
coun++;
continue;
}
}
}
x = X;
y = Y;
if (x + 1 < r)
{
x = X;
y = Y;
x = x + 1;
coun = 0;
while (1)
{
if (sea[x][y] == 'x')
{
if(mi>coun){
mi=coun;
last=3;
}
break;
}
if (sea[x][y] == '.')
{
break;
}
if (sea[x][y] == '>')
{
y++;
coun++;
continue;
}
if (sea[x][y] == '<')
{
y--;
coun++;
continue;
}
if (sea[x][y] == '^')
{
x--;
coun++;
continue;
}
if (sea[x][y] == 'v')
{
x++;
coun++;
continue;
}
}
}
x = X;
y = Y;
if (y - 1 >= 0)
{
x = X;
y = Y;
y = y - 1;
coun = 0;
while (1)
{
if (sea[x][y] == 'x')
{
if (mi > coun)
{
mi = coun;
last = 4;
}
break;
}
if (sea[x][y] == '.')
{
break;
}
if (sea[x][y] == '>')
{
y++;
coun++;
continue;
}
if (sea[x][y] == '<')
{
y--;
coun++;
continue;
}
if (sea[x][y] == '^')
{
x--;
coun++;
continue;
}
if (sea[x][y] == 'v')
{
x++;
coun++;
continue;
}
}
}
if(last==-1){
printf(":(\n");
return 0;
}
if (last == 1)
{
printf(":)\nE\n");
return 0;
}
if (last == 2)
{
printf(":)\nN\n");
return 0;
}
if (last == 3)
{
printf(":)\nS\n");
return 0;
}
if (last == 4)
{
printf(":)\nW\n");
return 0;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1088 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 |
- |