This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef int lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
typedef vector<ii> vii;
#define deb(x) cout << #x": " << (x) << endl;
vector <vi> adj;
vi tk;
lli curVis = 0;
void dfs(lli u){
tk[u] = curVis++;
for (auto & i : adj[u]){
if (tk[i] == -1) dfs(i);
}
}
vi label(lli n, lli k, vi u, vi v){
adj.resize(n, {});
tk.resize(n, -1ll);
curVis = 0;
fore(i,0,n-1){
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
// cout << u[i] << ' ' << v[i] << ENDL;
}
lli lst = 0;
fore(i,0,n) if (sz(adj[i]) == 1) lst = i;
// fore(i,0,n) cout << i << ": " << sz(adj[i]) << ENDL;
dfs(lst);
return tk;
}
lli find_next_station(lli s, lli t, vi c){
if (t > s) return s + 1;
return s - 1;
}
// int main(){ _
// // freopen("file.in","r",stdin);
// // freopen("file.out","w",stdout);
// lli n, k; cin >> n >> k;
// vi a(n-1); vi b(n-1);
// fore(i,0,n-1) cin >> a[i] >> b[i];
// vi v = label(n, k, a, b);
// // for (auto & i : v) cout << i << ' '; cout << ENDL;
// return 0;
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |