제출 #1296336

#제출 시각아이디문제언어결과실행 시간메모리
1296336eri16기지국 (IOI20_stations)C++20
0 / 100
396 ms504 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; vector<int> lbl; vector<int> vis; void dfs(int n, vector<vector<int>>& adj, int& depth) { if (vis[n]==0){ vis[n]=1; int in,ot; in=depth; depth++; for (int i=0; i<adj[n].size(); i++){ dfs(adj[n][i],adj,depth); } ot=depth; depth++; lbl[n]=in*1000+ot; } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { lbl.resize(n); vis.resize(n); vector<vector<int>> adj(n+1); for(int i=0; i<n-1; i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } int depth=0; dfs(0,adj,depth); return lbl; } int find_next_station(int s, int t, vector <int> cp){ int parent=-1; int in=s/1000; int ot=s%1000; for (int i=0; i<cp.size(); i++){ int k1,k2; k1=cp[i]/1000; k2=cp[i]%1000; if (k1<=in && ot<=k2){ parent=i; } } int ins=t/1000; int ots=t%1000; for (int i=0; i<cp.size() && i!=parent; i++){ int k1,k2; k1=cp[i]/1000; k2=cp[i]%1000; if (ins>=k1 && k2<=ots){ return cp[i]; } } return cp[parent]; }
#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...