Submission #1076646

#TimeUsernameProblemLanguageResultExecution timeMemory
1076646mindiyakStations (IOI20_stations)C++14
0 / 100
649 ms684 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(s>t)return c[0]; return c[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...