Submission #59934

# Submission time Handle Problem Language Result Execution time Memory
59934 2018-07-23T10:44:43 Z theknife2001 Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "crocodile.h"
#define ii pair < int , int >
#define fi first
#define se second


using namespace std;
vector < ii > vec[1005];
long long dp[1005];


void dfs(int u , int p)
{
    long long mn1,mn2;
    mn1=mn2=1e9+7;
    int v,c;
    for(auto x:vec[u])
    {
        v=x.fi;
        c=x.se;
        if(v==p)
            continue ;
        dfs(v,u);
        if(mn2>dp[v]+c)
            mn2=dp[v]+c;
        if(mn1>mn2)
            swap(mn1,mn2);
    }
    dp[u]=mn2;
    if(vec[u].size()==1)
        dp[u]=0;
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    for(int i=0;i<M;i++)
    {
        vec[R[i][1]].push_back({R[i][0],l[i]});
        vec[R[i][0]].push_back({R[i][1],l[i]});
    }
    dfs(0,0);
    cout<<dp[0]<<endl;
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:39:41: error: 'l' was not declared in this scope
         vec[R[i][1]].push_back({R[i][0],l[i]});
                                         ^
crocodile.cpp:39:46: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
         vec[R[i][1]].push_back({R[i][0],l[i]});
                                              ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/functional:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from crocodile.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}'
crocodile.cpp:40:46: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
         vec[R[i][0]].push_back({R[i][1],l[i]});
                                              ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/functional:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from crocodile.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}'
crocodile.cpp:44:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^