Submission #673939

#TimeUsernameProblemLanguageResultExecution timeMemory
673939vjudge1Stations (IOI20_stations)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const long long mod = 1988;
const long long mxN = 2e5 + 1;

vector<int> label(int n,int k, vector<int> u, vector<int> v){
    vector<vector<int>>gr;
    for(int i = 0;i < u.size();i++){
        gr[v[i]].push_back(u[i]);
        gr[u[i]].push_back(v[i]);
    }
    int labels[mxN];
    function<void(int,int,int)> dfs = [&](int node,int par,int val){
        val++;
        labels[i] = val;
        for(auto child : v[node]){
            if(child != par) dfs(child,node,val);
        }
    }
    dfs(0,-1,0);
    return labels;
}
int find_next_station(int s, int t, vector<int> c){
    int ans = 0;
    for(int i = 0;i < c.size();i++){
        if(c[i] < s && t < s){
            ans = c[i];
            return c[i];
        }
        if(c[i] <= t){
            ans = c[i];
        }else return ans;
    }
}

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:9:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i = 0;i < u.size();i++){
      |                   ~~^~~~~~~~~~
stations.cpp: In lambda function:
stations.cpp:16:16: error: 'i' was not declared in this scope
   16 |         labels[i] = val;
      |                ^
stations.cpp:17:32: error: 'begin' was not declared in this scope
   17 |         for(auto child : v[node]){
      |                                ^
stations.cpp:17:32: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from stations.cpp:1:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from stations.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
stations.cpp:17:32: error: 'end' was not declared in this scope
   17 |         for(auto child : v[node]){
      |                                ^
stations.cpp:17:32: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from stations.cpp:1:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from stations.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:21:5: error: expected ',' or ';' before 'dfs'
   21 |     dfs(0,-1,0);
      |     ^~~
stations.cpp:22:12: error: could not convert 'labels' from 'int [200001]' to 'std::vector<int>'
   22 |     return labels;
      |            ^~~~~~
      |            |
      |            int [200001]
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:26:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 0;i < c.size();i++){
      |                   ~~^~~~~~~~~~
stations.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^