이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/********************* بسم الله الرحمن الرحيم ***********************/
/******************** ٱلْحَمْدُ لِلَّٰهِ رَبِّ ٱلْعَالَمِينَ *************************/
/******************* Prophet Muhammad صلى الله عليه وسلم ************/
/*********************** وَقُل رَّبِّ زِدْنِي عِلْمًا **************************/
#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#else
#endif
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define in binary_search
#define ll long long
#define ld long double
#define Hey ios::sync_with_stdio(false);
#define Welcome cin.tie(NULL), cout.tie(NULL);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
const int M = 1e5 + 1;
const double inf = 1e15;
vector<pair<int,int>> nei[M];
double dijkstra(int h,vector<int> a)
{
int n=a.size();
double dis[n];
dis[0]=0;
for (int i=1;i<n;i++)
dis[i]=inf;
set<pair<int,int>> se;
se.insert({0,0});
while (!se.empty())
{
auto x=*se.begin();
int u=x.second,d=x.first;
se.erase(x);
if (u==h)
continue;
for (auto i:nei[u])
if (dis[i.first]>(double)(d+i.second)*a[i.first])
{
se.erase({dis[i.first],i.first});
dis[i.first]=(double)(d+i.second)*a[i.first];
se.insert({dis[i.first],i.first});
}
}
if (dis[h]==inf)
dis[h]=-1;
return dis[h];
}
double solve(int N,int m,int k,int H,vector<int> x,vector<int> y,vector<int> c,vector<int> a)
{
for (int i=0;i<N;i++)
nei[i].clear();
for (int i=0;i<m;i++)
{
nei[x[i]].push_back({y[i],c[i]});
nei[y[i]].push_back({x[i],c[i]});
}
return dijkstra(H,a);
}
# | 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... |