Submission #1288656

#TimeUsernameProblemLanguageResultExecution timeMemory
1288656blackscreen1꿈 (IOI13_dreaming)C++20
0 / 100
33 ms15612 KiB
#include "dreaming.h" #include <bits//stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; #define ll long long #define ld long double #define iloop(m, h) for (auto i = m; i != h; i += (m < h ? 1 : -1)) #define jloop(m, h) for (auto j = m; j != h; j += (m < h ? 1 : -1)) #define kloop(m, h) for (auto k = m; k != h; k += (m < h ? 1 : -1)) #define lloop(m, h) for (auto l = m; l != h; l += (m < h ? 1 : -1)) #define iloop_(m, h, g) for (auto i = m; i < h; i += g) #define jloop_(m, h, g) for (auto j = m; j < h; j += g) #define kloop_(m, h, g) for (auto k = m; k < h; k += g) #define lloop_(m, h, g) for (auto l = m; l < h; l += g) #define getchar_unlocked _getchar_nolock // comment before submission #define pll pair<ll, ll> #define plll pair<ll, pll> #define pllll pair<pll, pll> #define vll vector<ll> #define qll queue<ll> #define dll deque<ll> #define pqll priority_queue<ll> #define gll greater<ll> #define INF 1000000000000000 #define MOD1 1000000007 #define MOD2 998244353 #define MOD3 1000000009 mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); ll n, m; vector<pll> adj[100005]; vector<ll> dpts; bool vis[100005]; ll dpt[100005]; void dfs(ll nd, ll pr) { dpt[nd] = 0; vis[nd] = 1; for (auto it : adj[nd]) if (it.second != pr) {dfs(it.second, nd); dpt[nd] = max(dpt[nd], dpt[it.second] + it.first);} } void fmv(ll nd, ll pr, ll cl) { pll b1 = {cl, -1}, b2 = {0, -1}; for (auto it : adj[nd]) if (it.second != pr) { b2 = max(b2, min(b1, {dpt[it.second] + it.first, it.second})); b1 = max(b1, {dpt[it.second] + it.first, it.second}); } dpts.back() = min(dpts.back(), b1.first); for (auto it : adj[nd]) if (it.second != pr) { if (b1.second == it.second) fmv(it.second, nd, b2.first + it.first); else fmv(it.second, nd, b1.first + it.first); } } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { n = N, m = M; iloop(0, m) adj[A[i]].push_back({T[i], B[i]}), adj[B[i]].push_back({T[i], A[i]}); memset(vis, 0, sizeof(vis)); iloop(0, n) if (!vis[i]) { dfs(i, -1); dpts.push_back(INF); fmv(i, -1, 0); } sort(dpts.begin(), dpts.end()); //for (auto it : dpts) cout << it << " "; ll cv = dpts[0], ans = dpts[0]; iloop(1, (ll)dpts.size()) { ans = max(ans, cv + L + dpts[i]); cv = max(cv, dpts[i] + L); } return ans; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...