# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
984793 | Sir_Ahmed_Imran | Cyberland (APIO23_cyberland) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 100000
#define K 31
int t;
int ab[N];
int vis[N];
double dp[N];
vector<pll> a[N];
void dfs(int v){
if(vis[v] || v==t)
return;
vis[v]=1;
if(ab[v]==0)
dp[v]=0;
for(auto& i:a[v])
dfs(i.ff);
}
double solve(int n,int m,int k,int h,vector<int> x,vector<int> y,vector<int> c,vector<int> arr){
t=h;
ll p;
double q,r;
for(int i=0;i<n;i++){
ab[i]=arr[i];
dp[i]=-1e17;
}
for(int i=0;i<m;i++){
a[x[i]].append({y[i],c[i]});
a[y[i]].append({x[i],c[i]});
}
dfs(0);
r=1e17;
priority_queue<pair<double,int>> Q;
for(int j=dp[0]=0;j<=k;j++){
for(int i=0;i<n;i++){
Q.push({dp[i],i});
vis[i]=0;
}
while(!Q.empty()){
p=Q.top().ss;
q=Q.top().ff;
Q.pop();
if(!vis[p]){
vis[p]=1;
if(p==h){
r=min(r,-q);
continue;
}
dp[p]=q;
if(ab[p]==2)
dp[p]=q/2;
for(auto& i:a[p]){
if(!vis[i.ff])
Q.push({q-i.ss,i.ff});
}
}
}
}
if(r==1e17) r=-1;
return r;
}/*
int terminator(){
L0TA;
cout<<fixed<<setprecision(10);
cout<<solve(3, 2, 30, 2, {1, 2}, {2, 0}, {12, 4}, {1, 2, 1});
return 0;
}