QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#114494 | #4437. Link with Running | Liuf | WA | 625ms | 38876kb | C++20 | 1.3kb | 2023-06-22 11:29:25 | 2023-06-22 11:29:28 |
Judging History
answer
#include<bits/stdc++.h>
#define endl '\n'
#define pii pair<int, int>
#define int long long
using namespace std;
const int N=100010;
int n,m;
struct node{
int v,e,p;
};
vector<node>g[N];
int dis1[N],dis2[N];
void dijkstra(){
priority_queue<pii,vector<pii>,greater<pii>>q;
for(int i=2;i<=n;i++){
dis1[i]=1e18;
dis2[i]=-1e18;
}
vector<int>vis(n+1,0);
q.push({0,1});
while(q.size()){
auto [dis,u]=q.top();
q.pop();
if(vis[u])continue;
vis[u]=1;
for(auto [v,e,p]:g[u]){
if(dis1[v]>dis1[u]+e){
dis1[v]=dis1[u]+e;
dis2[v]=dis2[u]+p;
q.push({dis1[v],v});
} else if(dis1[v]==dis1[u]+e&&dis2[v]<dis2[u]+p){
dis2[v]=dis2[u]+p;
q.push({dis1[v],v});
}
}
}
}
void solve(){
cin>>n>>m;
for(int i=1;i<=n;i++){
g[i].clear();
}
for(int i=1;i<=m;i++){
int u,v,e,p;
cin>>u>>v>>e>>p;
g[u].push_back({v,e,p});
}
dijkstra();
cout<<dis1[n]<<' '<<dis2[n]<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 625ms
memory: 38876kb
input:
12 100000 200000 1 2 838279516 902819511 1 3 293478832 513256010 2 4 682688353 204481674 2 5 360092507 651108247 5 6 519851939 323803002 6 7 675439277 205804465 7 8 419167205 386168059 6 9 140767493 382483305 9 10 558115401 613738466 9 11 902235661 744659643 9 12 851394758 1720015 12 13 635355827 46...
output:
5927443549 11285847934 2529348 325344428756 2522027 438138599501 250100947 25049026205784 249512452 24966236662852 0 4880206195 0 6095137339 0 1000000000 0 1 0 2 0 1 0 1
result:
wrong answer 3rd lines differ - expected: '2522027 438209666288', found: '2522027 438138599501'