Submission #379472

#TimeUsernameProblemLanguageResultExecution timeMemory
379472rocks03Stations (IOI20_stations)C++14
0 / 100
920 ms1236 KiB
//#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...