Submission #1213807

#TimeUsernameProblemLanguageResultExecution timeMemory
121380712baater경주 (Race) (IOI11_race)C++20
Compilation error
0 ms0 KiB
#include "race.h"
#include <iostream>

using namespace std;

const long long MAX = 1E16;


vector<pair<int,int> > adj[200020];
long long current = 0;
long long len = 0;
long long best = MAX;
long long k;
long long n;

void dfs(int node, int parent) {
  if(current >= k) {
    if (current == k) {
      best = min(len,best);
    }
    return;
  }
  for(auto [child, cost] : adj[node]) {
    if(child == parent) continue;
    current += cost;
    len++;
    dfs(child, node);
    len--;
    current -= cost;
  }
}


int best_path(int N, int K, int H[][2], int L[]) {
  k = K;
  for (int i = 0; i < N-1; i++){ 
    adj[H[i][0]].emplace_back(H[i][1],L[i]);
    adj[H[i][1]].emplace_back(H[i][0],L[i]);
  }
  for(int i = 0; i < N; i++) {
    current = 0;
    len = 0;
    dfs(i,i);
  }
  return (best == MAX) ? -1 : best;
}

Compilation message (stderr)

race.cpp:9:1: error: 'vector' does not name a type
    9 | vector<pair<int,int> > adj[200020];
      | ^~~~~~
race.cpp: In function 'void dfs(int, int)':
race.cpp:23:28: error: 'adj' was not declared in this scope
   23 |   for(auto [child, cost] : adj[node]) {
      |                            ^~~
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:37:5: error: 'adj' was not declared in this scope
   37 |     adj[H[i][0]].emplace_back(H[i][1],L[i]);
      |     ^~~