이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* بسم الله الرحمن الرحيم *
﴾ رَبِّ اشْرَحْ لِي صَدْرِي * وَيَسِّرْ لِي أَمْرِي * وَاحْلُلْ عُقْدَةً مِّن لِّسَانِي * يَفْقَهُوا قَوْلِي ﴿
*/
/// author : "ASGA_RedSea"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
/// #include "lib.h"
vector <vector <pair <int,int>>> a;
vector <double> v;
vector <int> vis,s;
int h;
bool calc1(int i){
if(i == h)return 1;
for(auto& j : a[i]){
if(vis[j.first])continue;
vis[j.first]++;
if(calc1(j.first))return 1;
}
return 0;
}
double calc(int i,double time,int k,int last){
if(i == h)return time;
double ret = LLONG_MAX;
for(auto& [j,t] : a[i]){
if(j == last)continue;
if(s[j] == 0){
if(v[j] <= 0.0000000)continue;
v[j] = 0.0000000;
ret = min(ret,calc(j,0.0000000,k,i));
}
else if(s[j] == 1){
if(v[j] <= time + t)continue;
v[j] = time + t;
ret = min(ret,calc(j,time + t,k,i));
}
else{
if(v[j] <= time + t)continue;
if(k > 0)ret = min(ret,calc(j,(time + t) / 2,k - 1,i));
ret = min(ret,calc(j,time,k,i));
}
}
return ret;
}
double solve(int n,int m,int k,int H,vector <int> x,vector <int> y,vector <int> t,vector <int> aa){
a.resize(n + 1);h = H;s = aa;
for(int i = 0;i < m;i++){
a[x[i]].push_back({y[i],t[i]});
a[y[i]].push_back({x[i],t[i]});
}
vis = vector <int> (n + 1,0);
if(calc1(0) == 0)return -1;
v = vector <double> (n + 1,LLONG_MAX);
double ans = calc(0,0.00000000,k,-1);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |