답안 #366404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
366404 2021-02-14T06:43:23 Z VEGAnn Patkice (COCI20_patkice) C++14
50 / 50
1 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
const int oo = 2e9;
int n, m, ans = oo, sx, sy;
string pat = "ENSW";
char s[N][N], let = 'a';

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

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n >> m;

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

        if (s[i][j] == 'o'){
            sx = i;
            sy = j;
        }
    }

    for (int it = 0; it < 4; it++){
        int cx = sx, cy = sy, len = 1;

        if (it == 0)
            cy++;
        else if (it == 1)
            cx--;
        else if (it == 2)
            cx++;
        else cy--;

        while (1){
            if (s[cx][cy] == '.') break;
            if (s[cx][cy] == 'o') break;
            if (s[cx][cy] == 'x') {
                if (len < ans){
                    ans = len;
                    let = pat[it];
                }
                break;
            }

            len++;

            if (s[cx][cy] == '^')
                cx--;
            else if (s[cx][cy] == 'v')
                cx++;
            else if (s[cx][cy] == '>')
                cy++;
            else cy--;

        }
    }

    if (ans == oo)
        cout << ":(";
    else cout << ":)\n" << let;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct