Submission #1024344

#TimeUsernameProblemLanguageResultExecution timeMemory
1024344Ahmed_SolymanStations (IOI20_stations)C++14
0 / 100
3030 ms2097152 KiB
#include <bits/stdc++.h> using namespace std; #include "stations.h" typedef long long ll; vector<vector<int>>adj; vector<int>ret; int mark=0; void dfs(int node,int par){ ret[node]=mark++;; for(auto i:adj[node]){ if(i!=par)dfs(i,node); } } vector<int> label(int n, int k, vector<int> u, vector<int> v){ ret.resize(n); adj.resize(n); for(int i=0;i<n-1;i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } int root=0; for(int i=0;i<n;i++){ if(adj[i].size()==1)root=i; } dfs(root,root); return ret; } int find_next_station(int s, int t,vector<int> c){ if((int)c.size()==1)return c[0]; else if(t>s)return t+1; else return t-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...