Submission #421452

# Submission time Handle Problem Language Result Execution time Memory
421452 2021-06-09T07:38:04 Z usachevd0 Stations (IOI20_stations) C++17
0 / 100
893 ms 608 KB
#include <bits/stdc++.h>
#ifndef LOCAL
    #include "stations.h"
#endif

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define Time (clock() * 1.0 / CLOCKS_PER_SEC)
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using ld = long double;
template<typename T1, typename T2> bool chkmin(T1& x, T2 y) {
    return y < x ? (x = y, true) : false;
}
template<typename T1, typename T2> bool chkmax(T1& x, T2 y) {
    return y > x ? (x = y, true) : false;
}
void debug_out() {
    cerr << endl;
}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) {
    cerr << ' ' << A;
    debug_out(B...);
}
template<typename T> void mdebug_out(T* a, int n) {
    for (int i = 0; i < n; ++i)
        cerr << a[i] << ' ';
    cerr << endl;
}
#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    #define mdebug(a, n) cerr << #a << ": ", mdebug_out(a, n)
#else
    #define debug(...) 1337
    #define mdebug(a, n) 1337
#endif
template<typename T> ostream& operator << (ostream& stream, const vector<T>& v) {
    for (auto& e : v)
        stream << e << ' ';
    return stream;
}
template<typename T1, typename T2> ostream& operator << (ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << ' ' << p.second;
}

const int maxN = 1e3 + 3;
vector<int> G[maxN];
vector<int> ord;

void dfs(int v, int rev, int p = -1) {
    if (rev == 0) {
        ord.push_back(v);
        for (int u : G[v])
            if (u != p)
                dfs(u, 1, v);
    } else {
        for (int u : G[v])
            if (u != p)
                dfs(u, 0, v);
        ord.push_back(v);
    }
}


vector<int> label(int n, int __, vector<int> eu, vector<int> ev) {
    for (int v = 0; v < n; ++v) G[v].clear();
    for (int i = 0; i < n - 1; ++i) {
        int u = eu[i], v = ev[i];
        G[u].push_back(v);
        G[v].push_back(u);
    }
    ord.clear();
    dfs(0, 0);
    vector<int> pos(n);
    for (int i = 0; i < n; ++i)
        pos[ord[i]] = i;
    return pos;
}

int find_next_station(int s, int t, vector<int> g) {
    int rev;
    int sz = g.size();
    sort(all(g));
    if (s == 0 || s < g[0]) {
        int par = -1;
        if (s != 0) {
            par = g.back();
            g.pop_back();
        }
        if (s < t && t <= g.back()) {
            return *lower_bound(all(g), t);
        } else return par;
    } else {
        int par = g[0];
        g.erase(g.begin());
        if (g[0] <= t && t < s) {
            return *(upper_bound(all(g), t) - 1);
        } else return par;
    }
}

#ifdef LOCAL



int32_t main() {
    #ifdef LOCAL
        freopen("in", "r", stdin);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    
    
    
    return 0;
}
#endif

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:90:9: warning: unused variable 'rev' [-Wunused-variable]
   90 |     int rev;
      |         ^~~
stations.cpp:91:9: warning: unused variable 'sz' [-Wunused-variable]
   91 |     int sz = g.size();
      |         ^~
# Verdict Execution time Memory Grader output
1 Incorrect 658 ms 512 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 424 ms 516 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 689 ms 608 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 893 ms 400 KB Output is correct
2 Correct 740 ms 400 KB Output is correct
3 Incorrect 737 ms 536 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 608 ms 512 KB Wrong query response.
2 Halted 0 ms 0 KB -