Submission #1009941

#TimeUsernameProblemLanguageResultExecution timeMemory
1009941dimashhhStations (IOI20_stations)C++17
0 / 100
618 ms684 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 12; vector<int> g[N]; int timer = 0,tin[N],tout[N],dd[N]; void dfs(int v,int pr = -1,int depth = 0){ tin[v] = ++timer; dd[v] = depth; for(int to:g[v]){ if(to == pr) continue; dfs(to,v,depth+1); } tout[v] = ++timer; } vector<int> label(int n, int k,vector<int> u,vector<int> v){ vector<int> lab(n); timer = 0; for(int i = 0;i < n;i++){ g[i].clear(); } for(int i = 0;i < n - 1;i++){ g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } dfs(0); for(int i = 0;i < n;i++){ if(dd[i] & 1){ lab[i] = tout[i]; }else{ lab[i] = tin[i]; } // cout << i << ' ' << } return lab; } int find_next_station(int s, int t,vector<int> c){ if((int)c.size() == 1){ return c[0]; } int m = (int)c.size(); bool is_tin = false; if(s < c[0]){ is_tin = 1; } if(is_tin){ for(int i = 0;i < m - 1;i++){ int ti = s + 1; if(i){ ti = c[i - 1] + 1; } if(t >= i && t <= c[i]){ return c[i]; } } return c.back(); }else{ for(int i = 1;i < m;i++){ int ti = c[i],to = s - 1; if(i + 1 < m){ to = c[i + 1] - 1; } if(t >= ti && t <= to){ return c[i]; } } return c[0]; } }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:47:17: warning: variable 'ti' set but not used [-Wunused-but-set-variable]
   47 |             int ti = s + 1;
      |                 ^~
#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...