// ~ Be Name Khoda ~ //
#include "shortcut.h"
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int maxn = 1e6 + 10;
const int maxn5 = 3e3 + 10;
const int maxnt = 1.2e6 + 10;
const int maxn3 = 1e3 + 10;
const int mod = 1e9 + 7;
const int lg = 20;
const ll inf = 1e18;
int n;
ll c;
vector <ll> d;
ll ps[maxn5], ps2[maxn5], dis[maxn5];
set <pair<ll, int>> av;
vector <pair<int, ll>> adj[maxn5];
void bfs(int rt){
cout << rt << endl;
fill(dis, dis + n, inf);
av.clear();
dis[rt] = 0;
for(int i = 0; i < n; i++)
av.insert({dis[i], i});
for(int i = 0; i < n; i++){
if (av.empty()) return;
int v = av.begin()->se;
av.erase(av.begin());
for(auto [u, l] : adj[v]) if(dis[u] > dis[v] + l){
av.erase({dis[u], u});
dis[u] = dis[v] + l;
av.insert({dis[u], u});
}
}
}
long long find_shortcut(int N, std::vector<int> l, std::vector<int> D, int C)
{
n = N;
c = C;
for(auto u : D)
d.pb(u);
for(int i = 1; i < n; i++){
adj[i].pb({i - 1, l[i - 1]});
adj[i - 1].pb({i, l[i - 1]});
}
ll mn = inf;
for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){
adj[i].pb({j, c});
adj[j].pb({i, c});
ll mx = 0;
for(int x = 0; x < n; x++){
bfs(x);
for(int k = 0; k < n; k++) if(k != x)
mx = max(mx, dis[k] + d[k] + d[x]);
}
adj[i].pop_back();
adj[j].pop_back();
mn = min(mn, mx);
}
return mn;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |