답안 #464367

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464367 2021-08-13T05:46:17 Z dannyboy20031204 Patkice (COCI20_patkice) C++17
0 / 50
1000 ms 204 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define double long double
using namespace std;
void db() {cerr << endl;}
template <typename T, typename ...U> void db(T a, U ...b) {
    cerr << a << ' ', db(b...);
}
const int N = 100, inf = 1e9 + 1;
int n, m;
string a[N];
int solve(int x, int y){
    int ans = 1;
    while (a[x][y] != 'x'){
        ans++;
        if (a[x][y] == '.')
            return inf;
        else if (a[x][y] == '^')
            x--;
        else if (a[x][y] == 'v')
            x++;
        else if (a[x][y] == '<')
            y--;
        else
            y++;
    }
    return ans;
}
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> m;
    int x, y;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        for (int j = 0; j < m; j++)
            if (a[i][j] == 'o')
                x = i, y = j;
    }
    int ans = solve(x, y + 1);
    char d = 'E';
    if (ans > solve(x - 1, y))
        ans = solve(x - 1, y), d = 'N';
    if (ans > solve(x + 1, y))
        ans = solve(x + 1, y), d = 'S';
    if (ans > solve(x, y - 1))
        ans = solve(x, y - 1), d = 'W';
    if (ans == inf){
        cout << ":(";
    }
    else{
        cout << ":)\n";
        cout << d;
    }
}

Compilation message

patkice.cpp: In function 'int main()':
patkice.cpp:43:20: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |     if (ans > solve(x - 1, y))
      |               ~~~~~^~~~~~~~~~
patkice.cpp:43:20: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Execution timed out 1087 ms 204 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Execution timed out 1094 ms 204 KB Time limit exceeded
10 Halted 0 ms 0 KB -