Submission #904725

#TimeUsernameProblemLanguageResultExecution timeMemory
904725StefanL2005Race (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; ifstream in("file.in"); ofstream out("file.out"); #define inf 1000*1000*1000 void DFS(int node, int parent, vector<vector<int>> &vecin, vector<vector<int>> &cost, vector<int> &dist, vector<int> &path) { for (int i = 0; i < vecin[node].size(); i++) { auto V = vecin[node][i]; if (V == parent) continue; path[V] = path[node] + 1; dist[V] = dist[node] + cost[node][i]; DFS(V, node, vecin, cost, dist, path); } } int best_path(int n, int k, vector<vector<int>> H, vector<int> L) { int best_ans = inf; vector<int> dist; vector<int> path; vector<vector<int>> vecin(n), cost(n); for (int i = 0; i < H.size(); i++) { vecin[H[i][0]].push_back(H[i][1]); vecin[H[i][1]].push_back(H[i][0]); cost[H[i][0]].push_back(L[i]); cost[H[i][1]].push_back(L[i]); } for (int i = 0; i < n; i++) { dist = vector<int> (n); path = vector<int> (n); dist[i] = path[i] = 0; DFS(i, -1, vecin, cost, dist, path); for (int i = 0; i < n; i++) if (dist[i] == k) best_ans = min(best_ans, path[i]); } if (best_ans == inf) return -1; return best_ans; }

Compilation message (stderr)

race.cpp: In function 'void DFS(int, int, std::vector<std::vector<int> >&, std::vector<std::vector<int> >&, std::vector<int>&, std::vector<int>&)':
race.cpp:8:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int i = 0; i < vecin[node].size(); i++)
      |                     ~~^~~~~~~~~~~~~~~~~~~~
race.cpp: In function 'int best_path(int, int, std::vector<std::vector<int> >, std::vector<int>)':
race.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i = 0; i < H.size(); i++)
      |                     ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccsMLzkf.o: in function `main':
grader.cpp:(.text.startup+0x28): undefined reference to `best_path(int, int, int (*) [2], int*)'
collect2: error: ld returned 1 exit status