QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#411670 | #3788. Funny Car Racing | 23lpx | 0 | 33ms | 10856kb | C++14 | 1.3kb | 2024-05-15 17:30:46 | 2024-05-15 17:30:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int inf=1e12+99;
const int N=1e3+9;
int st[N],d[N];
int n,m,s,t,idx;
struct PII{
int d,a,b;
}g[N][N];
void init()
{
for(int i=1;i<=n;i++)
{
st[i]=0,d[i]=inf;
for(int j=1;j<=n;j++)
{
g[i][j].d=inf;
g[i][j].a=inf;
g[i][j].b=inf;
}
}
}
int dic(int d,int idx,int next)
{
int x=g[idx][next].a,y=g[idx][next].b;
int sum=x+y;
sum=d%sum;
if(sum+g[idx][next].d<=x)
{
return g[idx][next].d+d;
}
else
{
int res=d+x+y-sum;
res+=g[idx][next].d;
return res;
}
}
void djstl(int x)
{
d[s]=0;
while(x--)
{
int t=-1;
for(int i=1;i<=n;i++)
{
// printf("i=%lld t=%lld d[t]=%lld\n",i,t,d[t]);
if(st[i]==0&&(t==-1||d[i]<d[t]))
{
t=i;
}
}
st[t]=1;
for(int i=1;i<=n;i++)
{
// printf("t=%lld i=%lld dic=%lld\n",t,i,dic(d[t],t,i));
if(g[t][i].d!=inf)
d[i]=min(d[i],dic(d[t],t,i));
}
// printf("t=%lld\n",t);
// for(int i=1;i<=n;i++)printf("%lld ",d[i]);
// printf("\n");
}
int ans=d[t];
printf("Case %lld: %lld\n",++idx,ans);
}
void solve()
{
init();
while(m--)
{
int x,y,d,a,b;
cin>>x>>y>>a>>b>>d;
g[x][y]=g[y][x]={d,a,b};
}
djstl(n);
}
signed main()
{
ios::sync_with_stdio(0);cin.tie(0);
while(cin>>n>>m>>s>>t)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 33ms
memory: 10856kb
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: 877 Case 2: 9753 Case 3: 5801 Case 4: 1082 Case 5: 5601 Case 6: 1393 Case 7: 730 Case 8: 2041 Case 9: 582 Case 10: 1461 Case 11: 1058 Case 12: 370 Case 13: 7580 Case 14: 2808 Case 15: 764 Case 16: 791 Case 17: 1450 Case 18: 5889 Case 19: 1177 Case 20: 2367 Case 21: 2815 Case 22: 6667 Case 23...
result:
wrong answer 1st lines differ - expected: 'Case 1: 249', found: 'Case 1: 877'