Submission #1229570

#TimeUsernameProblemLanguageResultExecution timeMemory
1229570oscar1fStations (IOI20_stations)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
using pii = pair<int, int>;
int timer;
vector<int> tin, tout;
vector<pii> rv2;
vector<vector<int>> adj;
void dfs(int node, int p, int md2){
    tin[node]=timer++;
    for(auto thing:adj[node]){
        if(thing!=p)dfs(thing, node, md2^1);
    }
    tout[node]=timer++;
    rv2[node].first=(md2==0? tin[node]: tout[node]);
}
int[] label(int n, int l, int[] u, int[] v){
    tin.assign(n, 0);tout.assign(n,0);rv2.assign(n, {0, 0});adj.assign(n, {});
    timer=0;
    for(int i = 0;i<n;i++){
        rv2[i].second=i;
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }
    dfs(0, -1, 0);
    sort(all(rv2));
    int[n] reala;
    for(int i = 0;i<n;i++){
        reala[rv2[i].second]=rv2[i].first;
    }
}
int find_next_station(int s, int t, int[] c){
    if(c.size()==1)return c[0];
    int n = c.size();
    for(auto thing:s)if(thing==t)return s;
    if (s==c[0]){
        //s entry c exits
        int mye = c[n-2];
        if (t<s || t>mye)return c[n-1];
        for(auto thing:c)if(thing>=t)return thing;
    }
    else{
        int mye = c[1];
        if (t<mye || t>s)return c[0];
        for(int i = c.size()-1;i>=0;i--)if(c[i]<=t)return thing;
    }
}

Compilation message (stderr)

stations.cpp:17:4: error: structured binding declaration cannot have type 'int'
   17 | int[] label(int n, int l, int[] u, int[] v){
      |    ^~
stations.cpp:17:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
stations.cpp:17:4: error: empty structured binding declaration
stations.cpp:17:7: error: expected initializer before 'label'
   17 | int[] label(int n, int l, int[] u, int[] v){
      |       ^~~~~
stations.cpp:32:43: error: expected ',' or '...' before 'c'
   32 | int find_next_station(int s, int t, int[] c){
      |                                           ^
stations.cpp: In function 'int find_next_station(int, int, int*)':
stations.cpp:33:8: error: 'c' was not declared in this scope
   33 |     if(c.size()==1)return c[0];
      |        ^
stations.cpp:34:13: error: 'c' was not declared in this scope
   34 |     int n = c.size();
      |             ^
stations.cpp:35:20: error: 'begin' was not declared in this scope
   35 |     for(auto thing:s)if(thing==t)return s;
      |                    ^
stations.cpp:35:20: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from stations.cpp:1:
/usr/include/c++/11/valarray:1228:5: note:   'std::begin'
 1228 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/11/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
                 from stations.cpp:1:
/usr/include/c++/11/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
stations.cpp:35:20: error: 'end' was not declared in this scope
   35 |     for(auto thing:s)if(thing==t)return s;
      |                    ^
stations.cpp:35:20: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from stations.cpp:1:
/usr/include/c++/11/valarray:1255:5: note:   'std::end'
 1255 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
In file included from /usr/include/c++/11/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
                 from stations.cpp:1:
/usr/include/c++/11/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
stations.cpp:45:59: error: 'thing' was not declared in this scope; did you mean 'tin'?
   45 |         for(int i = c.size()-1;i>=0;i--)if(c[i]<=t)return thing;
      |                                                           ^~~~~
      |                                                           tin