Submission #1001132

#TimeUsernameProblemLanguageResultExecution timeMemory
1001132ZeroCoolStations (IOI20_stations)C++14
100 / 100
657 ms1124 KiB
#include "stations.h" #include <vector> #include <bits/stdc++.h> using namespace std; const int N = 1000; vector<int> g[N]; vector<int> A; int T = 0; void dfs(int x,int p, bool b){ if(b){ for(auto u: g[x]){ if(u == p)continue; dfs(u, x, !b); } A[x] = T++; }else{ A[x] = T++; for(auto u: g[x]){ if(u == p)continue; dfs(u, x, !b); } } } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { T = 0; A.clear(); A.resize(n); 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, 0,0 ); return A; } int find_next_station(int s, int t, std::vector<int> g) { if(g.size() == 1)return g.front(); sort(g.begin(), g.end()); if(s > g.front()){ if(t > s || t <= g.front())return g.front(); return *(upper_bound(g.begin(), g.end(), t) - 1); }else{ if(t < s | t >= g.back())return g.back(); return *lower_bound(g.begin(), g.end(), t); } }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:49:8: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   49 |   if(t < s | t >= g.back())return g.back();
      |      ~~^~~
#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...