답안 #495667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
495667 2021-12-19T20:37:25 Z asandikci Patkice (COCI20_patkice) C++17
0 / 50
0 ms 204 KB
#include"iostream"
// #include"vector"
// #include"queue"
// #include"deque"
// #include"set"
// #include"map"
// #include"algorithm"
// #include"iomanip"
// #include"cstring"
// #define int long long
using namespace std;

const int maxn=105;
const int INF = 1e9;

pair<int,int> duck;
char g[maxn][maxn];
int len=0;

void dfs(int x,int y){

  if(g[x][y]=='.' || g[x][y]=='o'){len=INF; return;}
  if(g[x][y]=='>'){ 
    len++;
    dfs(x,y+1);
  }
  if(g[x][y]=='<'){ 
    len++;
    dfs(x,y-1);
  }
  if(g[x][y]=='^'){ 
    len++;
    dfs(x-1,y);
  }
  if(g[x][y]=='v'){ 
    len++;
    dfs(x+1,y);
  }
  if(g[x][y]=='x') return;
}

void solve(){
  int n,m;
  cin >> n >> m;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> g[i][j];
      if(g[i][j]=='o'){
        duck = {i,j};
      }
    }
  }

  int a,b,c,d;
  // cout << duck.first << "*" << duck.second << "\n"; 
  dfs(duck.first,duck.second+1);
  a = len;
  len=0;
  dfs(duck.first,duck.second-1);
  b = len;
  len=0;
  dfs(duck.first+1,duck.second);
  c = len;
  len=0;
  dfs(duck.first-1,duck.second);
  d = len;

  cout << a << "  " << b << "  " << c << "  " << d << "\n\n"; 
  int mini = min(a,min(b,min(c,d)));
  if(mini==INF){cout << ":(";}
  else{
    cout << ":)\n";
    if(a==mini){cout << "E";}
    else if(b==mini){cout << "W";}
    else if(c==mini){cout << "S";}
    else if(d==mini){cout << "N";}  
  }
  




}

signed main(){
  // ios::sync_with_stdio(false); cin.tie(0);
  // freopen("","r",stdin);freopen("","w",stdout);
  int t=1;
  // cin >> t;
  for(int i=1;i<=t;i++){
    // cout << "Case " << i << ":\n";
    solve();
  }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -