제출 #880332

#제출 시각아이디문제언어결과실행 시간메모리
880332Mardonbekhazratov사이버랜드 (APIO23_cyberland)C++17
15 / 100
23 ms2396 KiB
#include "cyberland.h" #include<bits/stdc++.h> #include <vector> using namespace std; #define ll long long const ll INF=1e18; double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { bool subtask=true; for(int i=0;i<N;i++) if(arr[i]!=1) subtask=false; if(subtask){ vector<vector<pair<int,int>>>v(N); for(int i=0;i<M;i++){ v[x[i]].push_back({y[i],c[i]}); v[y[i]].push_back({x[i],c[i]}); } vector<bool>vis(N,0); priority_queue<pair<ll,int>>q; vector<ll>dp(N,INF); dp[0]=0; q.push({0,0}); while(!q.empty()){ int x=q.top().second; q.pop(); if(vis[x]) continue; vis[x]=true; for(auto [z,y]:v[x]){ if(dp[x]+y<dp[z]){ dp[z]=dp[x]+y; q.push({-dp[z],z}); } } } if(dp[H]==INF) return -1.0; return 1.0*dp[H]; } else{ int l=0,r=0; for(int i=1;i<H;i++){ if(arr[i]==2){ l=i; } if(arr[i]==0){ r=i; } } double ans=0.0; for(int i=r;i<H;i++){ ans+=c[i]; if(i==l){ for(int j=0;j<K;j++) ans/=2; } } 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...