Submission #424062

#TimeUsernameProblemLanguageResultExecution timeMemory
424062SupersonicStations (IOI20_stations)C++14
0 / 100
1150 ms512 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; vector<int> g[1005];int l[1005]; int d(int n,int a,int s,bool p){ int c=1;int f=s; for(auto i:g[n])if(i!=a){c+=d(i,n,f,!p);f=i;} if(p)l[n]=s+c; else l[n]=s-c; return c; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { for(int i=0;i<n-1;i++){g[u[i]].push_back(v[i]);g[v[i]].push_back(u[i]);} k=d(0,n,n,0);vector<int> r; for(int i=0;i<n;i++){r.push_back(l[i]);g[i].clear();} return r; } int find_next_station(int s, int t, std::vector<int> c) { if(s<c[0]){ if(t<s||t>=c.back())return c.back(); for(auto i:c)if(t<=i)return i; } else{ reverse(c.begin(),c.end()); if(t>s||t<=c.back())return c.back(); for(auto i:c)if(t>=i)return i; } exit(1); }
#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...