#include "crocodile.h"
#include <vector>
#include <utility>
using namespace std;
#define INF 9999999999
vector<vector<pair<int, int>>> tree;
vector<long long> times;
vector<int> visited;
void dfs(int n)
{
if(visited[n])
return;
else
visited[n] = 1;
if(times[n] == 0)
return;
vector<long long> temp;
for(int i = 0; i < tree[n].size(); i++)
{
dfs(tree[n][i].first);
temp.push_back(times[tree[n][i].first] + tree[n][i].second);
}
int minInd, curMin = INF;
for(int i = 0; i < temp.size(); i++)
{
if(curMin > temp[i])
{
curMin = temp[i];
minInd = i;
}
}
curMin = INF;
for(int i = 0; i < temp.size(); i++)
{
if(curMin > temp[i] && i != minInd)
curMin = temp[i];
}
if(curMin >= INF)
times[n] = INF:
else
times[n] = curMin;
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
tree.assign(N, vector<pair<int, int>>());
times.assign(N, INF);
visited.assign(N, 0);
for(int i = 0; i < N - 1; i++)
{
tree[R[i][0]].push_back(make_pair(R[i][1], L[i]));
tree[R[i][1]].push_back(make_pair(R[i][0], L[i]));
}
for(int i = 0; i < K; i++)
times[P[i]] = 0;
dfs(0);
return (int)times[0];
}
Compilation message
crocodile.cpp: In function 'void dfs(int)':
crocodile.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(int i = 0; i < tree[n].size(); i++)
| ~~^~~~~~~~~~~~~~~~
crocodile.cpp:7:13: warning: overflow in conversion from 'long int' to 'int' changes value from '9999999999' to '1410065407' [-Woverflow]
7 | #define INF 9999999999
| ^~~~~~~~~~
crocodile.cpp:31:26: note: in expansion of macro 'INF'
31 | int minInd, curMin = INF;
| ^~~
crocodile.cpp:32:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i = 0; i < temp.size(); i++)
| ~~^~~~~~~~~~~~~
crocodile.cpp:7:13: warning: overflow in conversion from 'long int' to 'int' changes value from '9999999999' to '1410065407' [-Woverflow]
7 | #define INF 9999999999
| ^~~~~~~~~~
crocodile.cpp:40:14: note: in expansion of macro 'INF'
40 | curMin = INF;
| ^~~
crocodile.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i = 0; i < temp.size(); i++)
| ~~^~~~~~~~~~~~~
crocodile.cpp:48:23: error: expected ';' before ':' token
48 | times[n] = INF:
| ^