Submission #1000741

# Submission time Handle Problem Language Result Execution time Memory
1000741 2024-06-18T08:01:14 Z nomuluun Race (IOI11_race) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, K;
ll H[200][2];
ll L[200];
vector<pair<int,int>>v[10000];
ll mi=INT_MAX;
void dfs(ll q, ll dis, ll hi, ll vis[1000]){
    if(dis==K){
        mi=min(mi,hi);
    }
    for(int i=0; i<v[q].size(); i++){
        int k=v[q][i].first;
        ll cost=v[q][i].second;
        if(!vis[k]){
            vis[k]=1;
            dfs(k,dis+cost,hi+1,vis);
        }
    }
}
int best_path(ll N, ll K, ll H[200005][2], ll L[200005]){
    for(int i=0; i<N-1; i++){
        ll vis[1000]={0};
        vis[i]=1;
        dfs(i,0,0,vis); //ehleh oroi distance highway
    }
    if(mi==INT_MAX)return -1;
    else return mi;
}
int main(){
    for(int i=0; i<N-1; i++){
        v[H[i][0]].push_back({H[i][1], L[i]});
        v[H[i][1]].push_back({H[i][0], L[i]});
    }
    best_path(N,K,H,L);
}

Compilation message

race.cpp: In function 'void dfs(ll, ll, ll, ll*)':
race.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0; i<v[q].size(); i++){
      |                  ~^~~~~~~~~~~~
/usr/bin/ld: /tmp/cc2QPa9B.o: in function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cccFydpB.o:grader.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cccFydpB.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