Submission #1076651

#TimeUsernameProblemLanguageResultExecution timeMemory
1076651mindiyakStations (IOI20_stations)C++14
5 / 100
645 ms936 KiB
#include "stations.h" #include <vector> #include <queue> #include <iostream> using namespace std; vector<vector<int>> paths(1001); vector<int> dist(1001,-1); void dfs(int pos,int len){ if(dist[pos] != -1)return; dist[pos] = len; for(int i:paths[pos])dfs(i,len+1); } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { std::vector<int> labels(n); paths = vector<vector<int>>(1001); dist = vector<int>(1001,-1); for(int i = 0;i<n-1;i++){ paths[u[i]].push_back(v[i]); paths[v[i]].push_back(u[i]); } int head = 0; for (int i = 0; i < n; i++) { if(paths[i].size() == 1){ head = i; } } dfs(head,0); // cerr << head << endl; for (int i = 0; i < n; i++) { labels[i] = dist[i]; // cerr << labels[i] << " "; } // cerr << endl; return labels; } int find_next_station(int s, int t, std::vector<int> c) { if (c.size() == 1) return c[0]; if(t>s)return c[1]; return c[0]; }
#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...