Submission #986575

#TimeUsernameProblemLanguageResultExecution timeMemory
986575CSQ31Stations (IOI20_stations)C++17
0 / 100
562 ms912 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++)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; for(int x:c){ int l = x/1000; int r = x%1000; if(l <= tl && tr <= r)return x; else if(out && l<=sl && sr<=sr)return x; } return c[0]; }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:41:29: warning: self-comparison always evaluates to true [-Wtautological-compare]
   41 |   else if(out && l<=sl && sr<=sr)return x;
      |                           ~~^~~~
#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...