Submission #334138

#TimeUsernameProblemLanguageResultExecution timeMemory
334138rocks03Stations (IOI20_stations)C++14
52.32 / 100
1005 ms1180 KiB
#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() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int M = 1000; int timer; vector<vector<int>> g; void dfs(int v, int p, vector<int>& labels){ int in = timer; for(auto u : g[v]){ if(u == p) continue; dfs(u, v, labels); } int ou = timer++; labels[v] = (M*in + ou); } vector<int> label(int n, int k, vector<int> u, vector<int> v){ g.resize(n); for(int i = 0; i < n; i++){ g[i].clear(); } for(int i = 0; i < n-1; i++){ g[u[i]].pb(v[i]); g[v[i]].pb(u[i]); } vector<int> labels(n); timer = 0; dfs(0, -1, labels); return labels; } int find_next_station(int s, int t, vector<int> c){ int in_s = s / M, ou_s = s % M; int in_t = t / M, ou_t = t % M; int id = -1; for(auto x : c){ int in_x = x / M, ou_x = x % M; if(in_x <= in_s && ou_s <= ou_x){ id = x; continue; } if(in_x <= in_t && ou_t <= ou_x){ return x; } } return id; }
#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...