QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#391672 | #3788. Funny Car Racing | ucup-team1251 | 0 | 39ms | 30308kb | C++17 | 1.9kb | 2024-04-16 17:59:41 | 2024-04-16 17:59:41 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define lson k << 1
#define rson (k << 1) | 1
#define debug cout << 666 << endl;
using namespace std;
const int N = 1e6 + 5;
int a[5][20];
int st[N];
int x, y;
typedef pair<int,int>PII;
typedef array<int,3>ar;
typedef array<int,4>ar4;
vector<ar4>E[N];
int dis[N];
int n,m;
int cn=0;
void dij(int s)
{
for(int i=1;i<=n;i++) dis[i]=1e18,st[i]=0;
priority_queue<PII,vector<PII>,greater<PII> >q;
q.push({0,s});
dis[s]=0;
while(q.size()!=0)
{
auto P=q.top();
q.pop();
int u=P.second;
if(st[u]==1) continue;
st[u]=1;
for(auto V:E[u])
{
int w=V[3];
int v=V[0];
int a=V[1];
int b=V[2];
int now=(dis[u])%(a+b);
if(w>a) continue;
int dti=0;
if(now>a)
{
dti=a+b-now+1;
dti+=w;
}
else
{
int ne=a-now;
if(w>ne)
{
dti=ne+b+w;
}
else dti=w;
}
if(dis[v]>dis[u]+dti)
{
dis[v]=dis[u]+dti;
q.push({dis[v],v});
}
}
}
}
void vision()
{
int s,t;
while (cin >> n >> m>>s>>t)
{
for(int i=1;i<=m;i++)
{
int u,v,w,a,b;
cin>>u>>v>>a>>b>>w;
if(a<t)
{
continue;
}
E[u].push_back({v,a,b,w});
E[v].push_back({u,a,b,w});
}
dij(s);
cout<<"Case "<<++cn<<": ";
cout<<dis[t]<<"\n";
for(int i=1;i<=n;i++) E[i].clear();
}
return;
}
signed main()
{
ios_base::sync_with_stdio(false);
// cin.tie(nullptr);
// cout.tie(nullptr);
int t = 1;
// cin >> t;
while (t--)
{
vision();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 39ms
memory: 30308kb
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: 1000000000000000000 Case 2: 1000000000000000000 Case 3: 1000000000000000000 Case 4: 1000000000000000000 Case 5: 1000000000000000000 Case 6: 1000000000000000000 Case 7: 560 Case 8: 1000000000000000000 Case 9: 1000000000000000000 Case 10: 1000000000000000000 Case 11: 1000000000000000000 Case 1...
result:
wrong answer 1st lines differ - expected: 'Case 1: 249', found: 'Case 1: 1000000000000000000'