Submission #1020538

#TimeUsernameProblemLanguageResultExecution timeMemory
1020538mansurShortcut (IOI16_shortcut)C++17
31 / 100
2070 ms8132 KiB
#include "shortcut.h" #include <bits/stdc++.h> using namespace std; #define rall(s) s.rbegin(), s.rend() #define all(s) s.begin(), s.end() #define sz(s) (int)s.size() #define s second #define f first using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const ll inf = 1e18, N = 1000; vector<pll> g[N]; ll d[N][N]; long long find_shortcut(int n, vector<int> l, vector<int> dt, int c) { for (int i = 0; i < n - 1; i++) { g[i].push_back({i + 1, l[i]}); g[i + 1].push_back({i, l[i]}); } for (int i = 0; i < n; i++) { g[i].push_back({i + n, dt[i]}); g[i + n].push_back({i, dt[i]}); } for (int i = 0; i < 2 * n; i++) { for (int j = 0; j < 2 * n; j++) d[i][j] = inf; priority_queue<pll> s; d[i][i] = 0; s.push({0, i}); while (sz(s)) { auto [dt, u] = s.top(); s.pop(); if (-dt != d[i][u]) continue; for (auto [to, w]: g[u]) { if (d[i][to] > d[i][u] + w) { d[i][to] = d[i][u] + w; s.push({-d[i][to], to}); } } } } ll ans = inf; for (int x = 0; x < n; x++) { for (int y = x + 1; y < n; y++) { ll res = 0; for (int a = n; a < 2 * n; a++) { for (int b = a + 1; b < 2 * n; b++) { ll v = min(d[a][b], d[a][x] + c + d[y][b]); v = min(v, d[a][y] + c + d[x][b]); res = max(res, v); } } ans = min(ans, res); } } 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...