제출 #1292797

#제출 시각아이디문제언어결과실행 시간메모리
1292797lambd47기지국 (IOI20_stations)C++20
0 / 100
3 ms484 KiB
#include<bits/stdc++.h> using namespace std; #define L(i,j,k) for(int i=(j);i<=(k);i++) #define R(i,j,k) for(int i=(j);i>=(k);i--) #define sz(v) ((int)(v).size()) #define all(v) (v).begin(),(v).end() #include "stations.h" std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { std::vector<int> dp(n); vector<vector<int>> adj(n); L(i,0,n-2){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } int tempo=0; auto dfs=[&](auto&& self, int node,int pai, int tipo){ if(tipo==0){ dp[node]=tempo*2; tempo++; } int x=0; for(auto a:adj[node]){ if(a==pai)continue; self(self,a,node,tipo^1); } if(tipo==1){ dp[node]=tempo*2+1; tempo++; } }; return dp; } int find_next_station(int s, int t, std::vector<int> c) { int n=sz(c); int tipo=s%2; s/=2; t/=2; L(i,0,n-1)c[i]/=2; if(tipo==0){//marca tempo de entrada e filhos tempo de saida if(s==0){ int id=0; while(c[id]<t)id++; return 2*c[id]+1; } else{ int pai=c.back(); //vejo se ta dentro do s if(t<s || t>c[n-2])return 2*pai+1; int id=0; while(c[id]<t)id++; return 2*c[id]+1; } } else{ int pai=c[0]; int id=n-1; if(t<c[1] || t>s)return 2*pai; while(c[id]>t)id--; return 2*c[id]; } }
#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...