답안 #962217

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

using namespace std;

struct edge
{
    int x,y;
    unsigned int dist;
    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 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])
{
    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:41:10: error: no matching function for call to 'edge::edge()'
   41 |     edge e,nb;
      |          ^
wombats.cpp:10:5: note: candidate: 'edge::edge(int, int, unsigned int)'
   10 |     edge(int xi, int yi, unsigned int di)
      |     ^~~~
wombats.cpp:10:5: note:   candidate expects 3 arguments, 0 provided
wombats.cpp:6:8: note: candidate: 'constexpr edge::edge(const edge&)'
    6 | struct edge
      |        ^~~~
wombats.cpp:6:8: note:   candidate expects 1 argument, 0 provided
wombats.cpp:6:8: note: candidate: 'constexpr edge::edge(edge&&)'
wombats.cpp:6:8: note:   candidate expects 1 argument, 0 provided
wombats.cpp:41:12: error: no matching function for call to 'edge::edge()'
   41 |     edge e,nb;
      |            ^~
wombats.cpp:10:5: note: candidate: 'edge::edge(int, int, unsigned int)'
   10 |     edge(int xi, int yi, unsigned int di)
      |     ^~~~
wombats.cpp:10:5: note:   candidate expects 3 arguments, 0 provided
wombats.cpp:6:8: note: candidate: 'constexpr edge::edge(const edge&)'
    6 | struct edge
      |        ^~~~
wombats.cpp:6:8: note:   candidate expects 1 argument, 0 provided
wombats.cpp:6:8: note: candidate: 'constexpr edge::edge(edge&&)'
wombats.cpp:6:8: note:   candidate expects 1 argument, 0 provided
wombats.cpp:50:51: warning: narrowing conversion of 'h[e.edge::x][(e.edge::y - 1)]' from 'int' to 'unsigned int' [-Wnarrowing]
   50 |             if(e.y>0) nb = {e.x,e.y-1,h[e.x][e.y-1]};
      |                                       ~~~~~~~~~~~~^
wombats.cpp:60:20: error: 'c' was not declared in this scope
   60 |             if(e.y<c-1) nb = {e.x,e.y+1,h[e.x][e.y]};
      |                    ^
wombats.cpp:60:51: warning: narrowing conversion of 'h[e.edge::x][e.edge::y]' from 'int' to 'unsigned int' [-Wnarrowing]
   60 |             if(e.y<c-1) nb = {e.x,e.y+1,h[e.x][e.y]};
      |                                         ~~~~~~~~~~^
wombats.cpp:70:20: error: 'r' was not declared in this scope
   70 |             if(e.x<r-1) nb = {e.x+1,e.y,v[e.x][e.y]};
      |                    ^
wombats.cpp:70:51: warning: narrowing conversion of 'v[e.edge::x][e.edge::y]' from 'int' to 'unsigned int' [-Wnarrowing]
   70 |             if(e.x<r-1) nb = {e.x+1,e.y,v[e.x][e.y]};
      |                                         ~~~~~~~~~~^
wombats.cpp:79:15: error: 'r' was not declared in this scope
   79 |     cout << d[r-1][V2] << endl;
      |               ^
wombats.cpp:80:1: warning: no return statement in function returning non-void [-Wreturn-type]
   80 | }
      | ^