이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "cyberland.h"
#include<fstream>
using namespace std;
ifstream fin("VNOICUP.INP");
ofstream fout("VNOICUP.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const int mxn = 1e5;
const ll prec = 1e-6;
struct ch{
int u, take; ld dd;
};
struct cmp{
bool operator()(const ch &a, const ch &b){
return(a.dd > b.dd);
}
};
vt<pii>adj[mxn + 1];
ld d[mxn + 1][71];
bool vis[mxn + 1], go[mxn + 1][71];
void dfs(int s){
vis[s] = 1;
for(auto [v, w]: adj[s]){
if(!vis[v])dfs(v);
}
}
double solve(int n, int m, int k, int h, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
k = min(k, 70);
forr(i, 0, n){
adj[i].clear();
forr(j, 0, k + 1){
d[i][j] = 1e18; go[i][j] = 0;
}
vis[i] = 0;
}
forr(i, 0, m){
int u = x[i], v = y[i], w = c[i];
adj[u].pb({v, w}); adj[v].pb({u, w});
}
dfs(0);
if(!vis[h])return(-1);
priority_queue<ch, vt<ch>, cmp>pq;
for(int i = 0; i < n; i++){
if(i == 0 || !arr[i]){
d[i][0] = 0; pq.push({i, 0, d[i][0]});
}
}
for(int tt = 0; tt <= k; tt++){
priority_queue<ch, vt<ch>, cmp>pq;
for(int i = 0; i < n; i++){
if(d[i][tt] != 1e18)pq.push({i, tt, d[i][tt]});
}
while(!pq.empty()){
auto [u, take, dd] = pq.top(); pq.pop();
if(abs(dd - d[u][take]) > prec || u == h)continue;
for(auto [v, w]: adj[u]){
if(d[v][take] > d[u][take] + w){
d[v][take] = d[u][take] + w;
pq.push({v, take, d[v][take]});
}
if(arr[v] == 2){
d[v][take + 1] = min(d[v][take + 1], (d[u][take] + w) / 2.0);
}
}
}
}
ld ans = 1e18;
for(int i = 0; i <= k; i++)ans = min(ans, d[h][i]);
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... |