Submission #833665

#TimeUsernameProblemLanguageResultExecution timeMemory
833665penguinmanStations (IOI20_stations)C++17
36.32 / 100
591 ms732 KiB
#include "stations.h" #include <bits/stdc++.h> #ifndef EVAL #include "stub.cpp" #endif using ll = int; using std::cin; using std::cout; using std::endl; using std::vector; using std::string; using vi = vector<ll>; using vii = vector<vi>; using pii = std::pair<ll,ll>; #define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++) #define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++) #define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--) #define ln "\n" #define pb emplace_back #define mp std::make_pair #define mtp std::make_tuple #define all(a) a.begin(), a.end() std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { constexpr int mod = 1001; int ord = 0; vi left(n, -1), right(n, -1); vii edge(n); rep(i,0,n-1){ edge[u[i]].pb(v[i]); edge[v[i]].pb(u[i]); } std::function<void(int)> dfs = [&](int now){ left[now] = ord++; for(auto next: edge[now]){ if(left[next] == -1) dfs(next); } right[now] = ord; }; dfs(0); vi num(n); rep(i,0,n) num[i] = left[i]*mod+right[i]; return num; } int find_next_station(int s, int t, std::vector<int> c) { constexpr int mod = 1001; int lt = t/mod, rt = t%mod; int ls = s/mod, rs = s%mod; if(ls <= lt && rt <= rs){ for(auto el: c){ int lc = el/mod, rc = el%mod; if(lc <= ls && rs <= rc) continue; if(lc <= lt && rt <= rc) return el; } } else{ for(auto el: c){ int lc = el/mod, rc = el%mod; if(lc <= ls && rs <= rc) return el; } } }

Compilation message (stderr)

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