Submission #961314

#TimeUsernameProblemLanguageResultExecution timeMemory
961314MackerStations (IOI20_stations)C++17
10 / 100
600 ms1120 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; #define ff first #define ss second #define all(v) v.begin(), v.end() #define FOR(i, n) for (int i = 0; i < n; i++) vector<int> in, out; vector<vector<int>> adj; int tim = 0; void dfs(int a, int p){ in[a] = tim++; for (auto b : adj[a]){ if(b != p) dfs(b, a); } out[a] = tim-1; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> labels(n); adj.assign(n, {}); in = out = vector<int>(n); FOR(i, n-1){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0, 0); FOR(i, n){ labels[i] = out[i] + 1000*in[i]; } return labels; } int find_next_station(int s, int t, vector<int> c) { int ins = s/1000; int outs = s%1000; int it = t/1000; if(ins <= it && outs >= it){ for (auto i : c) { int ii = i/1000; int oi = i%1000; if(ii > ins && ii <= it && oi >= it) return i; } } else{ for (auto i : c) { if(i / 1000 < ins) return i; } } }

Compilation message (stderr)

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