Submission #590230

#TimeUsernameProblemLanguageResultExecution timeMemory
590230fuad27Stations (IOI20_stations)C++17
10 / 100
993 ms644 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); for(int i = 0;i<n;i++) { tin[i]--; tout[i]--; } vector<int> l(n); for(int i = 0;i<n;i++) { l[i]=(2*1000-1)*tin[i]+tout[i]; } 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%(2000-1) <= c[i]%(2000-1) and s/(2000-1) >= c[i]/(2000-1)){ k=c[i]; continue; } if((c[i]%(2000-1)) >= t%(2000-1) and c[i]/(2000-1) <= t/(2000-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...