제출 #984794

#제출 시각아이디문제언어결과실행 시간메모리
984794Sir_Ahmed_Imran사이버랜드 (APIO23_cyberland)C++17
0 / 100
3064 ms10824 KiB
///~~~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; }
#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...