이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include"cyberland.h"
#define ld double
#define ll long long
#define fi first
#define se second
using namespace std ;
const int N = 1e5 ;
bool us[N] ;
ld dist[N] ;
vector<pair<int, int>> v[N] ;
void deikstra_for_one(int start)
{
for(int i = 0 ; i < N ; i++)
dist[i] = 1e18 ;
dist[start] = 0 ;
priority_queue<pair<ld, int>> s ;
s.push({0, start}) ;
while(s.size())
{
pair<ld, int> p = s.top() ;
s.pop() ;
if(us[p.se])
continue ;
us[p.se] = 1 ;
for(auto i : v[p.se])
{
if(us[i.fi] || dist[i.fi] <= -p.fi + i.se)
continue ;
dist[i.fi] = -p.fi + i.se ;
s.push({-dist[i.fi], i.fi}) ;
}
}
}
ld solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr)
{
// bool flag1 = 0 ;
// for(int i = 0 ; i < n ; i++)
// if(arr[i] != 1)flag1 = 1 ;
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]}) ;
}
deikstra_for_one(0) ;
if(dist[h] == 1e18)
return -1 ;
else
return dist[h] ;
}
//signed main()
//{
// ios_base::sync_with_stdio( 0 ) ;
// cin.tie( 0 ) ;
// cout.tie( 0 ) ;
// int n, m, k, h ;
// cin >> n >> m >> k >> h ;
// vector<int> a(m), b(m), c(m), arr(n) ;
// for(int i = 0 ; i < n ; i++)
// cin >> arr[i] ;
// for(int i = 0 ; i < m ; i++)
// cin >> a[i] >> b[i] >> c[i] ;
// cout << solve(n, m, k, h, a, b, c, arr) ;
// return 0 ;
//}
# | 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... |