Submission #1187323

#TimeUsernameProblemLanguageResultExecution timeMemory
1187323swishy123Stations (IOI20_stations)C++20
Compilation error
0 ms0 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include <random>
#include <chrono>
#include <set>
#include <map>
#include <stack>
#include <functional>
#include <iomanip>
#include <queue>
#include <cassert>
#include <complex>
#include <cstring>
#include <memory>
#include <bitset>
#include <sstream>
#include <cmath>
#include <numeric>
#include <numbers>
#include <fstream>
#include "stations.h"

using namespace std;

#ifndef template
#ifndef define
 
#define ll long long
#define ld long double
#define pl pair<ll, ll>
#define pi pair<int, int>
#define nl cout << '\n';
#define x first
#define y second 
#define cbit(x) __builtin_popcountll(x)
#define uid(a, b) uniform_int_distribution<ll>(a, b)(rng) 
#define siz(x) (int)x.size()
 
#endif
 
#ifndef print
void print(size_t x) {cout << x << ' ';}
void print(int x) {cout << x << ' ';}
void print(long long x) {cout << x << ' ';}
void print(float x) {cout << x << ' ';}
void print(long double x) {cout << x << ' ';}
void print(char x) {cout << x << ' ';}
void print(const char* x) {cout << x << ' ';}
void print(bool x) {cout << x << ' ';}
void print(string &x) {cout << x << ' ';}
 
template<typename T, typename V>
void print(pair<T, V> &p) {print(p.x); print(p.y);}
template<typename T>
void print(vector<T> v) {for (int i = 0; i < v.size(); i++) print(v[i]);}
template<typename T>
void print(vector<vector<T>> v) {
    for (int i = 0; i < v.size(); i++){
        for (int j = 0; j < v[i].size(); j++)
            print(v[i][j]);
        nl;
    }
}
template <typename T, typename... V>
void print(T t, V&&... v) {print(t); print(v...);}
 
#endif
 
#ifndef read
void read(int &x) {cin >> x;}
void read(long long &x) {cin >> x;}
void read(unsigned &x) {cin >> x;}
void read(unsigned long long &x) {cin >> x;}
void read(float &x) {cin >> x;}
void read(long double &x) {cin >> x;}
void read(char &x) {cin >> x;}
void read(string &x) {cin >> x;}
void read(bool &x) {cin >> x;}
 
template<typename T> 
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++)
        read(v[i]);
}
template <typename T, typename... V>
void read(T &t, V&... v) {read(t); read(v...);}
#endif
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> bool maxi(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
template<class T> bool mini(T& a, const T& b) {
    return a > b ? a = b, 1 : 0;
}
template<class... Args>
auto vec(size_t n, Args&&... args) {
    if constexpr(sizeof...(args) == 1)
        return vector(n, args...);
    else
        return vector(n, vec(args...));
}

#endif

using namespace std;
const ll inf = 1e18;
const ll def = 1e5+1;
const ll mod = 1e9+9;

using namespace std;

vector<int> label(int n, int k, vector<int> u, vector<int> v){
    vector<int> order(n);
    int indx = 0;

    auto dfs = [&](int u, int pre, int h, auto&& dfs) -> void{
        if (h % 2 == 0)
            order[u] = indx++;
        for (int v : edg[u]){
            if (v == pre)
                continue;
            dfs(v, u, h + 1, dfs);
        }
        if (h % 2 == 1)
            order[u] = indx++;
    };
    return order;
}

int find_next_station(int s, int t, vector<int> c){
	bool flag = 0;
    for (int u : c){
        if (u > s)
            flag = 1;
    }
    vector<pair<pi, int>> ranges;
    int parent = -1;

    if (!flag){
        for (int i = 0; i < c.size(); i++){
            if (i == 0)
                ranges.push_back({{s, c[i]}, c[i]});
            else    
                ranges.push_back({{c[i - 1] + 1, c[i]}, c[i]});
        }
        if (s != 0){
            ranges.pop_back();
            parent = c.back();
        }
    }   
    else{
        for (int i = 1; i < c.size(); i++){
            if (i == c.size() - 1)
                ranges.push_back({{c[i], s}, c[i]});
            else    
                ranges.push_back({{c[i], c[i + 1] - 1}, c[i]});
        }
        parent = c.front();
    }
    for (int i = 0; i < ranges.size(); i++){
        int u = ranges[i].y;
        auto [l, r] = ranges[i].x;

        if (t >= l && t <= r)
            return u;
    }
    return parent;
}

/*
2 1 2 3 1
*/

Compilation message (stderr)

stations.cpp: In lambda function:
stations.cpp:121:22: error: 'edg' was not declared in this scope
  121 |         for (int v : edg[u]){
      |                      ^~~