답안 #443013

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
443013 2021-07-09T13:23:18 Z LucaIlie Awesome Arrowland Adventure (eJOI19_adventure) C
컴파일 오류
0 ms 0 KB
#include <stdio.h>
#include <queue>
#include <vector>
#include <ctype.h>

#define MAX_N 500
#define DIR 4

using namespace std;

struct muchie {
    int nod, cost;
    bool operator < (const muchie &aux) const {
        return cost > aux.cost;
    }
};

int dist[MAX_N * MAX_N], dir[MAX_N + 2][MAX_N + 2];
int dl[DIR] = { -1, 0, 1, 0 }, dc[DIR] = { 0, 1, 0, -1 };
vector <muchie> muchii[MAX_N * MAX_N];
priority_queue <muchie> pq;

char nextChar() {
    char ch;

    ch = getc( stdin );
    while ( !isalpha( ch ) )
        ch = getc( stdin );

    return ch;
}

int main() {
    char ch;
    int n, m, l, c, d, i;
    struct muchie crt, next;

    scanf( "%d%d", &n, &m );
    for ( l = 1; l <= n; l++ ) {
        for ( c = 1; c <= m; c++ ) {
            ch = nextChar();
            if ( ch == 'N' )
                dir[l][c] = 0;
            else if ( ch == 'E' )
                dir[l][c] = 1;
            else if ( ch == 'S' )
                dir[l][c] = 2;
            else if ( ch == 'W' )
                dir[l][c] = 3;
            else
                dir[l][c] = 4;
        }
    }

    for ( l = 1; l <= n; l++ )
        dir[l][0] = dir[l][m + 1] = -1;
    for ( c = 1; c <= m; c++ )
        dir[0][c] = dir[n + 1][c] = -1;


    for ( l = 1; l <= n; l++ ) {
        for ( c = 1; c <= m; c++ ) {
            if ( dir[l][c] < 4 ) {
                for ( d = 0; d < DIR; d++ ) {
                    if ( dir[l + dl[d]][c + dc[d]] >= 0 )
                        muchii[(l - 1) * m + c - 1].push_back( { (l - 1 + dl[d]) * m + c - 1 + dc[d], (d - dir[l][c] + DIR) % DIR } );
                }
            }
        }
    }

    for ( i = 0; i < n * m; i++ )
        dist[i] = -1;

    pq.push( { 0, 0 } );
    while ( !pq.empty() ) {
        crt = pq.top();
        pq.pop();
        if ( dist[crt.nod] == -1 ) {
            dist[crt.nod] = crt.cost;
            for ( i = 0; i < muchii[crt.nod].size(); i++ ) {
                next = muchii[crt.nod][i];
                if ( dist[next.nod] == -1 )
                    pq.push( { next.nod, dist[crt.nod] + next.cost } );
            }
        }
    }

    printf( "%d ", dist[n * m - 1] );

    return 0;
}

Compilation message

adventure.c:2:10: fatal error: queue: No such file or directory
    2 | #include <queue>
      |          ^~~~~~~
compilation terminated.