답안 #237083

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
237083 2020-06-04T13:51:25 Z Autoratch 악어의 지하 도시 (IOI11_crocodile) C++14
컴파일 오류
0 ms 0 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<long long,int> 

const int N = 1e5 + 1;

vector<pair<int,int> > adj[N];
vector<int> ep;
priority_queue<pii,vector<pii>,greater<pii> > q;
long long dist[N];
bool visited[N];

long long dfs(int u)
{
    if(dist[u]==0) return 0;
    long long mn = LLONG_MAX,mn2 = LLONG_MAX;
    int m,m2;
    for(auto [d,v] : adj[u]) if(dist[v]<dist[u])
    {
        long long each = dfs(v)+d;
        if(each<mn) mn2 = mn,m2 = m,mn = each,m = v;
        else if(each<mn2) mn2 = each,m2 = v;
    }
    return mn2;
}

long long travel_plan(int n,int m,int r[][2],int l[],int k,int p[])
{
    for(int i = 0;i < m;i++)
    {
        int a = r[i][0],b = r[i][1],d = l[i];
        adj[a].push_back({d,b});
        adj[b].push_back({d,a});
    }
    for(int i = 0;i < k;i++) ep.push_back(p[i]);
    for(int i = 0;i < n;i++) dist[i] = LLONG_MAX;
    for(int x : ep) dist[x] = 0,q.push({0,x});
    while(!q.empty())
    {
        int u = q.top().second;
        q.pop();
        for(auto [d,v] : adj[u]) if(dist[u]+d<dist[v]) dist[v] = dist[u]+d,q.push({dist[v],v});
    }
    return dfs(0);
}

Compilation message

crocodile.cpp: In function 'long long int dfs(int)':
crocodile.cpp:19:14: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
     for(auto [d,v] : adj[u]) if(dist[v]<dist[u])
              ^
crocodile.cpp:18:11: warning: variable 'm2' set but not used [-Wunused-but-set-variable]
     int m,m2;
           ^~
crocodile.cpp: In function 'long long int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:28:11: error: ambiguating new declaration of 'long long int travel_plan(int, int, int (*)[2], int*, int, int*)'
 long long travel_plan(int n,int m,int r[][2],int l[],int k,int p[])
           ^~~~~~~~~~~
In file included from crocodile.cpp:1:0:
crocodile.h:1:5: note: old declaration 'int travel_plan(int, int, int (*)[2], int*, int, int*)'
 int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]);
     ^~~~~~~~~~~
crocodile.cpp:43:18: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
         for(auto [d,v] : adj[u]) if(dist[u]+d<dist[v]) dist[v] = dist[u]+d,q.push({dist[v],v});
                  ^