QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#413513 | #3788. Funny Car Racing | ggg | 0 | 40ms | 5544kb | C++20 | 1.3kb | 2024-05-17 17:31:28 | 2024-05-17 17:31:30 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<queue>
#include<cstdio>
using namespace std;
typedef pair<int,int> PII;
const int N=5e4+5;
int n,m,l,r;
int e[N],h[N],be[N],en[N],w[N],ne[N],cnt;
int dist[N],vis[N];
void join(int u,int v,int a,int b,int t)
{
e[cnt]=v;
be[cnt]=a;
en[cnt]=b;
w[cnt]=t;
ne[cnt]=h[u];
h[u]=cnt++;
}
int dijkstra()
{
dist[l]=0;
priority_queue<PII,vector<PII>,greater<>>p;
p.push({l,0});
while(p.size())
{
PII it=p.top();
p.pop();
int ver=it.first,time=it.second;
if(vis[ver])continue;
vis[ver]=1;
for(int i=h[ver];i!=-1;i=ne[i])
{
int j=e[i];
int Time=0;
if(time%(be[i]+en[i])+w[i]>be[i])
{
Time=time+be[i]+en[i]-time%(be[i]+en[i])+w[i];
}
else Time=time+w[i];
if(dist[j]>Time)
{
dist[j]=Time;
p.push({j,dist[j]});
}
}
}
return dist[r];
}
int main()
{
int k=0;
while(scanf("%d %d %d %d",&n,&m,&l,&r)!=EOF)
{
k++;
cnt=0;
int u,v,a,b,t;
for(int i=1;i<=max(n,m);i++)
{
dist[i]=1e9+100;
vis[i]=0;
h[i]=-1;
e[i]=be[i]=en[i]=ne[i]=w[i]=0;
}
for(int i=1;i<=m;i++)
{
scanf("%d %d %d %d %d",&u,&v,&a,&b,&t);
join(u,v,a,b,t);
}
printf("Case %d: %d\n",k,dijkstra());
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 40ms
memory: 5544kb
input:
155 9507 117 14 19 18 2 123 1 100 97 4 155 3 121 120 1 140 1 5 8 1 121 1 69 66 2 107 2 151 150 2 190 1 68 69 1 101 1 61 60 2 126 1 124 127 2 160 3 59 55 5 133 4 66 67 1 189 1 94 96 2 108 2 65 63 2 181 2 44 48 1 130 1 28 29 1 180 1 5 6 1 107 1 29 28 1 120 1 142 140 4 152 2 46 45 2 113 1 85 88 6 163 3...
output:
Case 1: 539 Case 2: 1540 Case 3: 1741 Case 4: 191 Case 5: 651 Case 6: 986 Case 7: 412 Case 8: 973 Case 9: 582 Case 10: 494 Case 11: 663 Case 12: 249 Case 13: 1574 Case 14: 873 Case 15: 390 Case 16: 257 Case 17: 442 Case 18: 613 Case 19: 685 Case 20: 316 Case 21: 470 Case 22: 799 Case 23: 1009 Case 2...
result:
wrong answer 1st lines differ - expected: 'Case 1: 249', found: 'Case 1: 539'