이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
const double inf = 1e15;
const int maxn=1e5+5;
int D[maxn];
vector<pair<int,double>>E[maxn];
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
for(int i = 0;i < M;i++){
E[x[i]].push_back({y[i],c[i]});
E[y[i]].push_back({x[i],c[i]});
}
for(int i = 1;i < N;i++) D[i] = 1e9;
deque<int>deq;
vector<bool>vis(N);
deq.push_back(0);
while(!deq.empty()){
int x = deq.front();
deq.pop_front();
if(vis[x]) continue;
vis[x] = 1;
for(auto i : E[x]){
if(D[x] + (arr[i.first] == 2) < D[i.first]){
D[i.first] = D[x] + (arr[i.first] == 2);
if(arr[i.first] != 2) deq.push_front(i.first);
else deq.push_back(i.first);
}
}
}
vector<int>zeros = {0};
vector<int>two;
for(int i = 1;i < N;i++) if(!arr[i]) zeros.push_back(i);
for(int i = 1;i < N;i++) if(arr[i] == 2) two.push_back(i);
priority_queue<pair<double,int>>q;
q.push({0,H});
double ans = inf;
double der = 1;
for(int i = 0;i <= K;i++){
vector<double>dis(N);
for(int j = 0;j < N;j++) dis[j] = inf;
while(!q.empty()){
int x = q.top().second;
double len = -q.top().first;
q.pop();
for(auto j : E[x]){
double now = (j.second / der) + len;
if(dis[j.first] > now){
dis[j.first] = now;
if(arr[j.first] == 1) q.push({-now,j.first});
}
}
}
for(auto j : zeros) if(D[j] + i <= K) ans = min(ans,dis[j]);
for(auto j : two) if(dis[j] < inf) q.push({-dis[j],j});
der *= 2;
}
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... |