Submission #1361638

#TimeUsernameProblemLanguageResultExecution timeMemory
1361638midari경주 (Race) (IOI11_race)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll best_path(ll n, ll k, ll H[][2], ll L[]){
    vector<ll>adj[200100];
    ll dist[1005][1005];
    for (i=1; i<n; i++){
        u=H[i][0];
        v=H[i][1];
        l=L[i];
        adj[u].push_back(v);
        adj[v].push_back(u);
        dist[u][v]=l;
        dist[v][u]=l;
    }
    ll e=LLONG_MAX;
    ll dfh1[200100],dfh2[200100];
    for (i=1; i<=n; i++){
        queue<ll>q;
        q.push(i);
        ll vis[n+5]={0};
        dfh1[i]=0;
        dfh2[i]=0;
        while (!q.empty()){
            ll a=q.front();
            q.pop();
            vis[a]=1;
            for (auto u : adj[a]){
                if (vis[u]!=1){
                    vis[u]=1;
                    q.push(u);
                    dfh1[u]=dfh1[a]+dist[a][u];
                    dfh2[u]=dfh2[a]+1;
                    if (dfh1[u]==k){
                        e=min(e,dfh2[u]);
                    }
                }
            }
        }
    }
    if (e==LLONG_MAX){
        return -1;
    }
    else {
        return e;
    }
}

Compilation message (stderr)

race.cpp: In function 'long long int best_path(long long int, long long int, long long int (*)[2], long long int*)':
race.cpp:8:10: error: 'i' was not declared in this scope
    8 |     for (i=1; i<n; i++){
      |          ^
race.cpp:9:9: error: 'u' was not declared in this scope
    9 |         u=H[i][0];
      |         ^
race.cpp:10:9: error: 'v' was not declared in this scope
   10 |         v=H[i][1];
      |         ^
race.cpp:11:9: error: 'l' was not declared in this scope
   11 |         l=L[i];
      |         ^
race.cpp:19:10: error: 'i' was not declared in this scope
   19 |     for (i=1; i<=n; i++){
      |          ^