QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#856398 | #8627. 归程 | neilliu | 0 | 1ms | 4096kb | C++17 | 2.3kb | 2025-01-13 22:27:06 | 2025-01-13 22:27:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mk make_pair
struct EDGE {
int u,v,w,a,b;
}e[8005];
int t[1005],w[1005];
double p[1005];
vector<int> edge[1005];
int n,m,k,x,y;
int dis[1005];
long double ans[1005];
bool vis[1005];
priority_queue<pair<int,int> ,vector< pair<int,int> >,greater< pair<int,int> > > q;
priority_queue<pair<long double,int> ,vector< pair<long double,int> >,greater< pair<long double,int> > > q1;
void dijkstra1(int st){
memset(dis,0x7f,sizeof(dis));
dis[st] = 0;
q.push(mk(0,st));
while(q.size()){
int nowx = q.top().second; q.pop();
if(vis[nowx]) continue;
vis[nowx] = 1;
for(int i : edge[nowx]){
int u = e[i].u,v = e[i].v,l = e[i].w;
if(dis[v] > dis[u] + l){
dis[v] = dis[u] + l;
q.push(mk(dis[v],v));
}
}
}
}
void dijkstra2(int st){
for(int i = 1; i <= n; i++) ans[i] = 1e12;
memset(vis,0,sizeof(vis));
ans[st] = 0;
q1.push(mk(0,st));
while(q1.size()){
int nowx = q1.top().second; q1.pop(); printf("%d ",nowx);
//cerr << nowx << " ";
if(vis[nowx]) continue;
vis[nowx] = 1;
for(int i : edge[nowx]){
int u = e[i].u,v = e[i].v,l = e[i].w;
int zuo = dis[u],you = dis[u] + l;
long double zong = 0;
for(int j = 1; j <= k; j++){
long double sum = 0;
if(t[j] <= zuo){
sum = (long double)l * (long double)e[i].b;
}else if(you <= t[j]){
sum = (long double)l * (long double)e[i].a;
}else{
sum = (long double)(t[j] - zuo) * (long double)e[i].a + (long double)(you - t[j]) * (long double)e[i].b;
}
zong += sum * p[j];
}
if(ans[v] > ans[u] + zong){
q1.push(mk(ans[v],v));
ans[v] = ans[u] + zong;
}
}
}
}
signed main()
{
scanf("%lld%lld%lld%lld%lld",&n,&m,&k,&x,&y);
long double sum = 0;
for(int i = 1; i <= m; i++){
scanf("%lld%lld%lld%lld%lld",&e[i].u,&e[i].v,&e[i].w,&e[i].a,&e[i].b);
e[i+m].u = e[i].v,e[i+m].v = e[i].u,e[i+m].w = e[i].w,e[i+m].a = e[i].a,e[i+m].b = e[i].b;
edge[e[i].u].emplace_back(i);
edge[e[i].v].emplace_back(i+m);
}
for(int i = 1; i <= k; i++){
scanf("%lld%lld",&t[i],&w[i]);
sum += w[i];
}
for(int i = 1; i <= k; i++) p[i] = (long double)w[i] / sum;
dijkstra1(x);
dijkstra2(x);
//for(int i = 1; i <= n; i++) cerr << ans[i] << " " ;
printf("%Lf\n",ans[y]);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3968kb
input:
100 99 50 44 13 1 2 3 49482 98172 3 2 14 15325 20412 3 4 17 72195 82332 4 5 2 5759 58007 6 5 17 74543 88637 6 7 8 30091 53620 7 8 6 25345 52430 9 8 13 256 54988 10 9 9 8715 9170 10 11 7 16469 60748 11 12 2 88501 90578 12 13 20 32990 42921 13 14 7 10662 18700 14 15 17 5604 94646 16 15 4 30714 75974 1...
output:
44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 13265304...
result:
wrong answer 1st numbers differ - expected: '13265304.0930924', found: '44.0000000', error = '0.9999967'
Subtask #2:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 1ms
memory: 4096kb
input:
100 400 1 3 100 10 1 13 18223 35112 1 2 12 55368 55369 11 2 17 26761 33328 10 11 16 32129 40781 3 12 11 54283 82995 19 20 14 61623 64279 4 13 19 68053 68404 28 29 12 51572 76296 5 14 17 60900 80188 37 38 19 4559 88722 6 15 18 70161 98792 46 66 18 31418 46063 7 16 12 59448 73370 74 75 16 61790 91015 ...
output:
3 2 1 4 5 6 7 16 7 8 17 9 10 11 1 60 19 56 7 9 20 33 26 17 52 56 25 24 33 34 16 15 14 50 87 42 28 41 74 67 11 12 85 74 13 22 58 68 87 23 39 14 45 67 18 70 69 68 8 42 71 58 72 51 23 80 39 41 79 73 45 44 45 77 50 83 53 81 100 71 54 14 15 16 17 18 19 20 21 30 23 84 53 93 39 31 20 98 83 54 66 22 23 24 2...
result:
wrong answer 1st numbers differ - expected: '565023.0000000', found: '3.0000000', error = '0.9999947'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%