이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define all(s) s.begin(),s.end()
#define F first
#define S second
using namespace std;
typedef int ll;
ll n,m,x,y;
char c[109][109];
pair<ll,char>ans;
ll go(ll i,ll j)
{
if(c[i][j]=='x')
return 0;
if(c[i][j]=='.'||c[i][j]=='o')
return 1e9;
if(c[i][j]=='>')
return go(i,j+1)+1;
if(c[i][j]=='<')
return go(i,j-1)+1;
if(c[i][j]=='^')
return go(i-1,j)+1;
return go(i+1,j)+1;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>n>>m;
for(ll i=0; i<n; i++)
for(ll j=0; j<m; j++)
{
cin>>c[i][j];
if(c[i][j]=='o')
x=i,y=j;
}
ans.F=1e9;
ans=min({go(x-1,y),'N'},ans);
ans=min({go(x+1,y),'S'},ans);
ans=min({go(x,y+1),'E'},ans);
ans=min({go(x,y-1),'W'},ans);
if(ans.F>=1e9)
cout<<":(";
else
cout<<":)\n"<<ans.S;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |