Submission #590242

#TimeUsernameProblemLanguageResultExecution timeMemory
590242fuad27Stations (IOI20_stations)C++17
10 / 100
1228 ms532 KiB
#include "stations.h" #include <vector> #include<bits/stdc++.h> using namespace std; #define pb push_back const int N = 1010; typedef long long ll; vector<int> g[N]; vector<int> tin, tout; int cnt=0; void dfs(int at, int p) { tin[at]=cnt++; for(int to:g[at]) { if(to != p)dfs(to, at); } tout[at]=cnt; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { cnt=0; tin.clear(); tout.clear(); tin.resize(n); tout.resize(n); for(int i = 0;i<n-1;i++) { g[u[i]].pb(v[i]); g[v[i]].pb(u[i]); } dfs(0, 0); vector<int> l(n); for(int i = 0;i<n;i++) { l[i]=(1000-1)*tin[i]+tout[i]; // cout << l[i] << "\n"; } for(int i = 0;i<=n;i++)g[i].clear(); return l; } int find_next_station(int s, int t, std::vector<int> c) { int k =0; for(int i=0;i<(int)c.size();i++) { if(s%(1000-1) <= c[i]%(1000-1) and s/(1000-1) >= c[i]/(1000-1)){ k=c[i]; continue; } if((c[i]%(1000-1)) >= t%(1000-1) and c[i]/(1000-1) <= t/(1000-1))return c[i]; } return k; }
#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...