답안 #495650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
495650 2021-12-19T18:46:47 Z AlperenT Patkice (COCI20_patkice) C++17
0 / 50
0 ms 204 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 100 + 5, INF = 1e9 + 5;

int n, m, ans = INF, x, y, dist;

char c, arr[N][N];

int dfs(int x, int y){
    if(arr[x][y] == 'x') return 0;
    else{
        if(arr[x][y] == '^') return min(dfs(x - 1, y), INF);
        else if(arr[x][y] == '>') return min(dfs(x, y + 1), INF);
        else if(arr[x][y] == '<') return min(dfs(x, y - 1), INF);
        else if(arr[x][y] == 'v') return min(dfs(x + 1, y), INF);
        else return INF;
    }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    cin >> n >> m;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> arr[i][j];

            if(arr[i][j] == 'o') x = i, y = j;
        }
    }

    if(dist = dfs(x - 1, y) <= ans) ans = dist, c = min(c, 'N');
    if(dist = dfs(x, y + 1) <= ans) ans = dist, c = min(c, 'E');
    if(dist = dfs(x, y - 1) <= ans) ans = dist, c = min(c, 'W');
    if(dist = dfs(x + 1, y) <= ans) ans = dist, c = min(c, 'S');

    if(ans == INF) cout << ":(";
    else cout << ":)\n" << c;
}

Compilation message

patkice.cpp: In function 'int main()':
patkice.cpp:35:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   35 |     if(dist = dfs(x - 1, y) <= ans) ans = dist, c = min(c, 'N');
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~~~
patkice.cpp:36:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   36 |     if(dist = dfs(x, y + 1) <= ans) ans = dist, c = min(c, 'E');
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~~~
patkice.cpp:37:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   37 |     if(dist = dfs(x, y - 1) <= ans) ans = dist, c = min(c, 'W');
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~~~
patkice.cpp:38:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   38 |     if(dist = dfs(x + 1, y) <= ans) ans = dist, c = min(c, 'S');
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 -