답안 #758259

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
758259 2023-06-14T10:19:56 Z ivaziva 악어의 지하 도시 (IOI11_crocodile) C++14
컴파일 오류
0 ms 0 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;

#define MAXN 1010

int travel_plan(int N,int M,int R[][2],int L[],int K,int P[])
{
    long long n;
    long long m;
    long long k;
    vector<pair<long long long>> adj[MAXN];
    long long niz[MAXN];
    long long dist1[MAXN];
    long long dist2[MAXN];
    long long pos[MAXN];
    n=N; m=M; k=K;
    for (long long i=0;i<m;i++)
    {
        long long x=R[i][0];
        long long y=R[i][1];
        long long z=L[i];
        adj[x].push_back({y,z});
        adj[y].push_back({x,z});
    }
    for (long long i=0;i<MAXN;i++)
    {
        dist1[i]=LLONG_MAX;
        dist2[i]=LLONG_MAX;
    }
    priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> pq;
    for (long long i=0;i<k;i++)
    {
        niz[i+1]=P[i-1];
        pq.push({0,niz[i+1]});
        dist1[niz[i+1]]=0;
        dist2[niz[i+1]]=0;
        pos[niz[i+1]]=1;
    }
    while (pq.empty()==false)
    {
        long long node=pq.top().second;
        long long dist0=pq.top().first;
        pq.pop();
        if (dist0>dist2[node0]) continue;
        if (pos[node]>1) continue;
        long long s=adj[node0].size();
        for (long long i=0;i<s;i++)
        {
            long long node=adj[node0][i].first;
            long long dist=adj[node0][i].second;
            if (dist0+dist<dist1[node])
            {
                dist2[node]=dist1[node];
                dist1[node]=dist0+dist;
                pq.push({dist1[node],node});
            }
            else if (dist0+dist<dist2[node])
            {
                dist2[node]=dist0+dist;
                pq.push({dist2[node],node});
            }
        }
        pos[node0]++;
    }
    return (int)dist2[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:13:27: error: 'long long long' is too long for GCC
   13 |     vector<pair<long long long>> adj[MAXN];
      |                           ^~~~
crocodile.cpp:13:27: error: wrong number of template arguments (1, should be 2)
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from crocodile.cpp:2:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
  211 |     struct pair
      |            ^~~~
crocodile.cpp:13:31: error: template argument 1 is invalid
   13 |     vector<pair<long long long>> adj[MAXN];
      |                               ^~
crocodile.cpp:13:31: error: template argument 2 is invalid
crocodile.cpp:24:16: error: request for member 'push_back' in 'adj[x]', which is of non-class type 'int'
   24 |         adj[x].push_back({y,z});
      |                ^~~~~~~~~
crocodile.cpp:25:16: error: request for member 'push_back' in 'adj[y]', which is of non-class type 'int'
   25 |         adj[y].push_back({x,z});
      |                ^~~~~~~~~
crocodile.cpp:46:25: error: 'node0' was not declared in this scope; did you mean 'node'?
   46 |         if (dist0>dist2[node0]) continue;
      |                         ^~~~~
      |                         node
crocodile.cpp:48:25: error: 'node0' was not declared in this scope; did you mean 'node'?
   48 |         long long s=adj[node0].size();
      |                         ^~~~~
      |                         node