제출 #1056896

#제출 시각아이디문제언어결과실행 시간메모리
1056896c2zi6기지국 (IOI20_stations)C++14
21 / 100
502 ms948 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "stations.h" VVI gp; VI ret; int last; void dfs(int u, int p = -1) { ret[u] = last++; for (int v : gp[u]) if (v != p) { dfs(v, u); if (p == -1) last += 1000; } } VI label(int n, int k, VI U, VI V) { gp = VVI(n); rep(i, n-1) { int u = U[i]; int v = V[i]; gp[u].pb(v); gp[v].pb(u); } ret = VI(n); last = 0; int s = -1; rep(u, n) if (gp[u].size() > 2) s = u; else if (gp[u].size() == 1 && s == -1) s = u; dfs(s); /*for (int x : ret) cout << x << " "; cout << endl;*/ return ret; } int find_next_station(int s, int t, VI c) { if (c.size() == 1) return c[0]; if (s == 0) { rep(i, c.size()) { if (c[i]%1000 > t%1000) return c[i-1]; } return c.back(); } if (t/1000 != s/1000) return c[0]; if (t > s) return c[1]; return c[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...