Submission #379472

# Submission time Handle Problem Language Result Execution time Memory
379472 2021-03-18T09:56:16 Z rocks03 Stations (IOI20_stations) C++14
0 / 100
920 ms 1236 KB
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define Re(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 1e3;
vector<int> g[MAXN+10];

int N, timer, tin[MAXN+10], tou[MAXN+10];
void dfs(int v, int p, vector<int>& labels){
    tin[v] = timer++;
    for(int u : g[v]){
        if(u ^ p){
            dfs(u, v, labels);
        }
    }
    tou[v] = timer - 1;
    labels[v] = MAXN * tin[v] + tou[v];
}

vector<int> label(int N, int K, vector<int> u, vector<int> v){
    :: N = N;
    rep(i, 0, N){
        g[i].clear();
    }
    auto add_edge = [&](int a, int b){
        g[a].pb(b);
        g[b].pb(a);
    };
    rep(i, 0, N - 1){
        add_edge(u[i], v[i]);
    }
    vector<int> labels(N);
    timer = 0;
    dfs(0, -1, labels);
    return labels;
}

int find_next_station(int a, int b, vector<int> c){
    auto get_label = [&](int x){
        pii ans = {x / MAXN, x % MAXN};
        return ans;
    };
    auto ancestor = [&] (pii u, pii v){
        bool is = (u.ff <= v.ff && v.ss <= u.ss);
        return is;
    };
    pii s = get_label(a), t = get_label(b);
    for(int x : c){
        pii u = get_label(x);
        if(ancestor(s, u)){
            if(ancestor(u, t))
                return x;
        } else{
            if(ancestor(t, u))
                return x;
        }
    }
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:71:1: warning: control reaches end of non-void function [-Wreturn-type]
   71 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 364 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1188 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 920 ms 1108 KB Output is correct
2 Runtime error 3 ms 1236 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1132 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -