Submission #986583

#TimeUsernameProblemLanguageResultExecution timeMemory
986583CSQ31Stations (IOI20_stations)C++17
52.32 / 100
583 ms1700 KiB
#include "stations.h" #include<bits/stdc++.h> using namespace std; vector<int>adj[1000]; int tin[1000],tout[1000]; int timer = -1; void dfs(int v,int u){ tin[v] = ++timer; for(int x:adj[v]){ if(x==u)continue; dfs(x,v); } tout[v] = timer; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for(int i=0;i<n;i++)adj[i].clear(); vector<int>lab(n); for(int i=0;i+1<n;i++){ adj[v[i]].push_back(u[i]); adj[u[i]].push_back(v[i]); } timer = -1; dfs(0,-1); //for(int i=0;i<n;i++)cout<<tin[i]<<" "<<tout[i]<<'\n'; for(int i=0;i<n;i++)lab[i] = 1000*tin[i] + tout[i]; return lab; } int find_next_station(int s, int t, vector<int> c) { int tl = t/1000; int tr = t%1000; int sl = s/1000; int sr = s%1000; bool out = 1; if(sl <= tl && tr <= sr)out = 0; //cout<<sl<<" "<<sr<<" "<<tl<<" "<<tr<<'\n'; for(int x:c){ int l = x/1000; int r = x%1000; if(l <= sl && sr <= r){ if(out)return x; } else if(l <= tl && tr <= r)return x; } }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
#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...