Submission #800549

#TimeUsernameProblemLanguageResultExecution timeMemory
800549LiudasStations (IOI20_stations)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
void dfs(int head, int par, vector<vector<int>> &tree, int &col, vector<int> &labels){
    for(int i : tree[head]){
        if(i != par){
            dfs(i, head, tree, col, labels);
        }
    }
    labels[head] = col ++;
}
int find_next_station(int s, int t, vector<int> labels){
    sort(labels.begin(), labels.end());
    for(int i : labels){

    }
    if(t >= labels.back()){
        return labels.back();
    }
    for(int i : labels){
        if(t <= i){
            return i;
        }
    }
}
vector<int> label(int N, int K, vector<int> U, vector<int> V){
    vector<vector<int>> tree(N);
    for(int i = 0; i < N-1; i ++){
        tree[U[i]].push_back(V[i]);
        tree[V[i]].push_back(U[i]);
    }
    vector<int> labels(N);
    iota(labels.begin(), labels.end());
    int col = 0;
    for(int i = 0; i < N; i ++)if(tree[i].size() > 2)
    dfs(i, -1, tree, col, labels);

    return labels;
}

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:14:13: warning: unused variable 'i' [-Wunused-variable]
   14 |     for(int i : labels){
      |             ^
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:33:38: error: no matching function for call to 'iota(std::vector<int>::iterator, std::vector<int>::iterator)'
   33 |     iota(labels.begin(), labels.end());
      |                                      ^
In file included from /usr/include/c++/10/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_numeric.h:88:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::iota(_ForwardIterator, _ForwardIterator, _Tp)'
   88 |     iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
      |     ^~~~
/usr/include/c++/10/bits/stl_numeric.h:88:5: note:   template argument deduction/substitution failed:
stations.cpp:33:38: note:   candidate expects 3 arguments, 2 provided
   33 |     iota(labels.begin(), labels.end());
      |                                      ^
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:25:1: warning: control reaches end of non-void function [-Wreturn-type]
   25 | }
      | ^