Submission #66371

#TimeUsernameProblemLanguageResultExecution timeMemory
66371mirbek01Shortcut (IOI16_shortcut)C++17
0 / 100
3 ms560 KiB
# include "shortcut.h" # include <bits/stdc++.h> using namespace std; const int N = 1e3 + 2; int vr, n; long long sum, d[N]; vector < pair <int, int> > g[N]; vector <int> vec; void dfs(int v){ for(int i = 0; i < n; i ++) d[i] = 1e18; d[v] = 0; set < pair <long long, int> > st; st.insert({0, v}); while(!st.empty()){ int vv = st.begin()->second; st.erase(st.begin()); for(auto to : g[vv]){ if(d[vv] + to.second < d[to.first]){ st.erase({to.first, d[to.first]}); d[to.first] = d[vv] + to.second; st.insert({d[to.first], to.first}); } } } sum = 0; for(int i = 0; i < n; i ++){ long long cur = vec[v] + d[i]; if(i != v) cur += vec[i]; if(sum < cur){ sum = cur; vr = i; } } } long long find_shortcut(int NN, vector<int> l, vector<int> d, int c){ n = NN; long long ans = 1e18; for(int i = 0; i < n - 1; i ++){ g[i].push_back({i + 1, l[i]}); g[i + 1].push_back({i, l[i]}); } vec = d; for(int i = 1; i < n; i ++){ for(int j = 2 + 1; j < n; j ++){ g[i].push_back({j, c}); g[j].push_back({i, c}); dfs(0); dfs(vr); ans = min(ans, sum); g[i].pop_back(); g[j].pop_back(); } } 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...