Submission #964631

#TimeUsernameProblemLanguageResultExecution timeMemory
964631irmuun기지국 (IOI20_stations)C++17
76 / 100
605 ms1708 KiB
#include<bits/stdc++.h> #include "stations.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() const int N=1e3+5; vector<int>adj[N],tin(N),tout(N),dep(N); int cur=0; void dfs(int x,int p){ tin[x]=cur++; for(auto y:adj[x]){ if(y!=p){ dep[y]=dep[x]+1; dfs(y,x); } } tout[x]=cur++; } vector<int>label(int n,int k,vector<int>u,vector<int>v){ cur=0; for(int i=0;i<n;i++){ adj[i].clear(); } for(int i=0;i<n-1;i++){ adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } dfs(0,-1); vector<int>l(n); for(int i=0;i<n;i++){ if(dep[i]%2==0){ l[i]=tin[i]; } else{ l[i]=tout[i]; } } return l; } int find_next_station(int s,int t,vector<int>c){ if(s<c[0]){ int l=s+1; for(int i=0;i<(int)c.size()-1;i++){ if(l<=t&&t<=c[i]){ return c[i]; } l=c[i]+1; } return c.back(); } else{ int r=s-1; for(int i=(int)c.size()-1;i>0;i--){ if(c[i]<=t&&t<=r){ return c[i]; } r=c[i]-1; } return c[0]; } return 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...