답안 #962218

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
962218 2024-04-13T09:10:14 Z serkanrashid 웜뱃 (IOI13_wombats) C++14
0 / 100
26 ms 40028 KB
#include "wombats.h"
#include <bits/stdc++.h>

using namespace std;

struct edge
{
    int x,y;
    unsigned int dist;
    edge(){};
    edge(int xi, int yi, unsigned int di)
    {
        x = xi;
        y = yi;
        dist = di;
    }
    bool operator<(const edge&ed) const
    {
        return dist>ed.dist;
    }
};

int r,c;
int h[5000][200],v[5000][200];
unsigned int d[5000][200],inf = -1;

void changeH(int P, int Q, int W)
{
    h[P][Q] = W;
}

void changeV(int P, int Q, int W)
{
    v[P][Q] = W;
}

int escape(int V1, int V2)
{
    memset(d,-1,sizeof(d));
    priority_queue<edge>q;
    d[0][V1] = 0;
    q.push({0,V1,0});
    edge e,nb;
    while(!q.empty())
    {
        e = q.top();
        q.pop();
        if(e.dist<=d[e.x][e.y])
        {
            ///LEFT
            nb = {0,0,inf};
            if(e.y>0) nb = {e.x,e.y-1,h[e.x][e.y-1]};
            if(nb.dist!=inf&&e.dist+nb.dist<d[nb.x][nb.y])
            {
                nb.dist += e.dist;
                d[nb.x][nb.y] = nb.dist;
                q.push(nb);
            }

            ///RIGHT
            nb = {0,0,inf};
            if(e.y<c-1) nb = {e.x,e.y+1,h[e.x][e.y]};
            if(nb.dist!=inf&&e.dist+nb.dist<d[nb.x][nb.y])
            {
                nb.dist += e.dist;
                d[nb.x][nb.y] = nb.dist;
                q.push(nb);
            }

            ///DOWN
            nb = {0,0,inf};
            if(e.x<r-1) nb = {e.x+1,e.y,v[e.x][e.y]};
            if(nb.dist!=inf&&e.dist+nb.dist<d[nb.x][nb.y])
            {
                nb.dist += e.dist;
                d[nb.x][nb.y] = nb.dist;
                q.push(nb);
            }
        }
    }
    cout << d[r-1][V2] << endl;
}

void init(int R, int C, int H[5000][200], int V[5000][200])
{
    r = R;
    c = C;
    for(int i=0;i<R;i++)
        for(int j=0;j<C-1;j++) h[i][j] = H[i][j];

    for(int i=0;i<R-1;i++)
        for(int j=0;j<C;j++) v[i][j] = V[i][j];

}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
wombats.cpp: In function 'int escape(int, int)':
wombats.cpp:52:51: warning: narrowing conversion of 'h[e.edge::x][(e.edge::y - 1)]' from 'int' to 'unsigned int' [-Wnarrowing]
   52 |             if(e.y>0) nb = {e.x,e.y-1,h[e.x][e.y-1]};
      |                                       ~~~~~~~~~~~~^
wombats.cpp:62:51: warning: narrowing conversion of 'h[e.edge::x][e.edge::y]' from 'int' to 'unsigned int' [-Wnarrowing]
   62 |             if(e.y<c-1) nb = {e.x,e.y+1,h[e.x][e.y]};
      |                                         ~~~~~~~~~~^
wombats.cpp:72:51: warning: narrowing conversion of 'v[e.edge::x][e.edge::y]' from 'int' to 'unsigned int' [-Wnarrowing]
   72 |             if(e.x<r-1) nb = {e.x+1,e.y,v[e.x][e.y]};
      |                                         ~~~~~~~~~~^
wombats.cpp:82:1: warning: no return statement in function returning non-void [-Wreturn-type]
   82 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 30040 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 12888 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 21544 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 40028 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 21304 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 18 ms 21340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -