제출 #1196649

#제출 시각아이디문제언어결과실행 시간메모리
1196649Mousa_Aboubaker사이버랜드 (APIO23_cyberland)C++20
97 / 100
3094 ms171076 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) { vector adj(N, vector<pair<int, int>>()); for (int i = 0; i < M; i++) { adj[x[i]].push_back({y[i], c[i]}); adj[y[i]].push_back({x[i], c[i]}); } K = min(K, 100); vector dp(N, vector<long double>(K + 1, 1e15)); dp[0][0] = 0; queue<tuple<int, int>> q; q.push({0, 0}); while(not q.empty()) { auto [u, c] = q.front(); q.pop(); for(auto [v, w]: adj[u]) { if(arr[v] == 0 and dp[v][c] != 0) { dp[v][c] = 0; q.push({v, c}); continue; } long double curr = dp[u][c] + w; if(dp[v][c] > curr) { dp[v][c] = curr; if(v != H) q.push({v, c}); } if(arr[v] == 2 and c < K) { long double curr2 = (dp[u][c] + w) / 2; if(dp[v][c + 1] > curr2) { dp[v][c + 1] = curr2; q.push({v, c + 1}); } } } } long double res = 1e15; for(int i = 0; i <= K; i++) res = min(res, dp[H][i]); if(res == 1e15) res = -1; return res; }
#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...