Submission #373624

#TimeUsernameProblemLanguageResultExecution timeMemory
373624Jarif_RahmanStations (IOI20_stations)C++17
0 / 100
3036 ms3116 KiB
#include "stations.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; vector<vector<int>> v; vector<int> lb, sz; pair<int, int> div(int x){ return make_pair(x/1000, x%1000); } int in = 0; void dfs(int nd, int ss){ lb[nd] = in++; for(int x: v[nd]) if(x!=ss) dfs(x, nd); for(int x: v[nd]) if(x!=ss) sz[nd]+=sz[x]; lb[nd]+=sz[nd]*1000; } vector<int> label(int n, int k, vector<int> aa, vector<int> bb){ v.assign(n, {}); lb.resize(n); sz.resize(n, 1); for(int i = 0; i < n-1; i++){ v[aa[i]].pb(bb[i]); v[bb[i]].pb(aa[i]); } dfs(0, -1); for(int x: lb) cerr << x << " "; cerr << " d\n"; return lb; } int find_next_station(int s, int t, vector<int> c){ sort(c.begin(), c.end(), [&](int a, int b){return div(a).sc < div(b).sc;}); auto [a, b] = div(s); cerr << s << " " << t << " d\n"; cerr << a << " " << b << " " << div(t).f << " " << div(t).sc << " d\n"; if(div(t).sc < b || div(t).sc > b+a) return c.front(); c.erase(c.begin()); for(int x: c){ auto [aa, bb] = div(x); if(t > bb && t <= bb+aa) return x; } }

Compilation message (stderr)

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