Submission #930136

# Submission time Handle Problem Language Result Execution time Memory
930136 2024-02-18T16:18:14 Z quanlt206 Stations (IOI20_stations) C++17
0 / 100
558 ms 940 KB
#include "stations.h"
#include<bits/stdc++.h>
#define X first
#define Y second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define mxx max_element
#define mnn min_element
#define SQR(x) (1LL * (x) * (x))
#define MASK(i) (1LL << (i))
#define Point Vector
#define left Left
#define right Right
#define div Div

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;

template<class A, class B>
    bool maximize(A& x, B y) {
        if (x < y) return x = y, true; else return false;
    }
template<class A, class B>
    bool minimize(A& x, B y) {
        if (x > y) return x = y, true; else return false;
    }
/* END OF TEMPLATE */

const int N = 1e3 + 7;

vector<int> v[N];

int st[N], ed[N], cnt = 0, high[N];
int lab[N];

void dfs(int x, int par) {
    st[x] = ++cnt;
    for (auto y : v[x])
        if (y != par) {
            high[y] = high[x] + 1;
            dfs(y, x);
        }
    ed[x] = ++cnt;
}

vector<int> label(int n, int k, vector<int> a, vector<int> b) {
    REP(i, 0, n) v[i].clear();
    REP(i, 0, n - 1) {
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    cnt = 0;
    dfs(0, 0);
    REP(i, 0, n)
        if (high[i] == 0) lab[i] = st[i]; else lab[i] = ed[i];
    vector<int> res(lab, lab + n);
//    for (auto x : res) cout<<x<<" "; cout<<"\n";
    return res;
}

int find_next_station(int s, int t, vector<int> c) {
    sort(all(c));
    if (binary_search(all(c), t)) return t;
    int n = c.size();
    if (s < c[0]) {
        // s thoi diem vao
        if (s != 0) {
            // check xem t co nam ngoai cay con goc s hay khong
            if (t < s || t > c[n - 2]) return c[n - 1]; // return cha
        }
        for (auto x : c)
            if (x > t) return x;
    }
    // s thoi diem ra
    if (s != 0) {
        if (t > s || t < c[1]) return c[0];
    }
    int res = 0;
    for (auto x : c)
        if (x <= t) res = x;
    return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 584 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1991
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 544 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1023
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 344 ms 940 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 558 ms 684 KB Output is correct
2 Correct 370 ms 684 KB Output is correct
3 Incorrect 366 ms 684 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 344 ms 936 KB Wrong query response.
2 Halted 0 ms 0 KB -