Submission #621457

#TimeUsernameProblemLanguageResultExecution timeMemory
621457misteg168Stations (IOI20_stations)C++17
5 / 100
1008 ms644 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; void dfs(ll node, vector<vector<ll>> & adj, vector<bool> & vis, vector<int> & labels, ll it){ vis[node] = 1; labels[node] = it; for(auto x : adj[node]){ if(vis[x]) continue; it++; dfs(x, adj, vis, labels, it); } } vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { cout << "\n"; vector<int> labels(n); vector<vector<ll>> adj(n); for(int i = 0; i < (ll)u.size(); i++){ adj[ u[i] ].push_back( v[i] ); adj[ v[i] ].push_back( u[i] ); } for(int i = 0; i < n; i++){ if(adj[i].size() == 1){ ll it = 0; vector<bool> vis(n); dfs( i, adj, vis, labels, it); break; } } return labels; } int find_next_station(int s, int t, std::vector<int> c){ sort(c.begin(), c.end()); if(t > s && s != 0){ 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...