제출 #719361

#제출 시각아이디문제언어결과실행 시간메모리
719361mseebacher기지국 (IOI20_stations)C++17
0 / 100
811 ms688 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; #define MAXI (int)1e3+10 vector<int> ad[MAXI]; vector<int> labels; // 1 .. 1e3 // 1e3+1 ... 2e3 void dfs(int x,int e){ if(e > 0){ labels[x] = labels[e]+1e3; } for(auto s: ad[x]){ if(s == e) continue; dfs(s,x); } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { labels.assign(n,0); for(int i = 0;i<MAXI;i++) ad[i].clear(); for(int i = 0;i<n-1;i++){ ad[u[i]].push_back(v[i]); ad[v[i]].push_back(u[i]); } int start = 0; for(int i = 0;i<n;i++){ if(ad[i].size() >= 3){ start = i; break; } } int cnt = 1; for(auto s: ad[start]){ labels[s] = cnt; cnt++; } labels[start] = 0; dfs(start,-1); return labels; } int find_next_station(int s, int t, std::vector<int> c) { if(s%1000 != t%1000){ if(s == 0) return t%1000; return s > 999 ? s-1e3 : 0; } return s > t ? s-1e3 : s+1e3; }
#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...