Submission #578578

#TimeUsernameProblemLanguageResultExecution timeMemory
578578VanillaStations (IOI20_stations)C++17
100 / 100
996 ms912 KiB
#include <bits/stdc++.h> #include "stations.h" using namespace std; const int maxn = 1002; vector <int> ad [maxn]; int ct = 0; int get_nd (int x) { return x / 2; } void dfs (int u, int p, int dp, vector <int> &lb) { if (dp % 2 == 0) lb[u] = ct++; int mx = 0; for (int v: ad[u]) { if (v == p) continue; dfs(v, u, dp + 1, lb); } if (dp % 2 == 1) lb[u]=ct++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> labels(n); vector <int> norm (n); ct = 0; for (int i = 0; i < n; i++){ ad[i].clear(); } for (int i = 0; i < n - 1; i++){ ad[u[i]].push_back(v[i]); ad[v[i]].push_back(u[i]); } dfs(0, -1, 0, labels); return labels; } int find_next_station(int s, int t, vector<int> c) { if (c[0] > s) { if (t < s) return c.back(); auto it = lower_bound(c.begin(), c.end(), t); if (it == c.end()) it--; return *it; } if (t > s) return c[0]; auto it = upper_bound(c.begin(), c.end(), t); if (it != c.begin()) it--; return *it; }

Compilation message (stderr)

stations.cpp: In function 'void dfs(int, int, int, std::vector<int>&)':
stations.cpp:14:6: warning: unused variable 'mx' [-Wunused-variable]
   14 |  int mx = 0;
      |      ^~
#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...