Submission #524515

# Submission time Handle Problem Language Result Execution time Memory
524515 2022-02-09T11:39:42 Z Turkhuu Stations (IOI20_stations) C++17
Compilation error
0 ms 0 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> label(int n, int k, vector<int> U, vector<int> V){
  vector<vector<int>> g(n);
  for(int i = 0; i < n - 1; i++){[
    g[U[i]].push_back(V[i]);
    g[V[i]].push_back(U[i]);
  }
  vector<int> a(n);
  int x = 0;
  function<void(int, int)> dfs = [&](int u, int anc){
    a[u] = x++;
    for(int v : g[u]){
      if(v != anc){
        dfs(v, u);
      }
    }
  };
  for(int i = 0; ; i++){
    if((int)g[i].size() == 1){
      dfs(i, i);
      return a;
    }
  }
}

int find_next_station(int s, int t, vector<int> c){
  if(s > t){
    return *min_element(c.begin(), c.end());
  } else{
    return *max_element(c.begin(), c.end());
  }
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:9:6: error: expected ',' before '[' token
    9 |     g[U[i]].push_back(V[i]);
      |      ^
      |      ,
stations.cpp:9:6: error: expected identifier before '[' token
stations.cpp:9:28: error: expected ']' before ';' token
    9 |     g[U[i]].push_back(V[i]);
      |                            ^
      |                            ]
stations.cpp: In lambda function:
stations.cpp:9:28: error: expected '{' before ';' token