QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#197340 | #4437. Link with Running | yiyiyi# | WA | 254ms | 47376kb | C++14 | 2.1kb | 2023-10-02 14:47:38 | 2023-10-02 14:47:39 |
Judging History
answer
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<bitset>
#include<set>
#define int long long
#define lowbit(x) x&(-x)
#define mp make_pair
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define forE(i,x) for(int i=head[x];i;i=nxt[i])
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int maxm=6e5+5;
const int maxn=2e5+5;
const int mod=998244353;
inline int read()
{
int x=0,f=1;char c=getchar();
while(c<'0'||c>'9')
{
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9')
{
x=x*10+(c-'0');
c=getchar();
}
return x*f;
}
int T;
int n,m;
int cnt,ver[maxm],nxt[maxm],head[maxn],w[maxm],val[maxm];
inline void add(int x,int y,int z,int l)
{
cnt++;
ver[cnt]=y;
val[cnt]=z;
w[cnt]=l;
nxt[cnt]=head[x];
head[x]=cnt;
}
const int INF=1e18;
int d[maxn];
bool bj[maxn];
inline void dijkstra(int s)
{
rep(i,0,n) d[i]=INF;
rep(i,0,n) bj[i]=0;
d[s]=0;
priority_queue<pii> q;
q.push(mp(0,s));
while(!q.empty())
{
int x=q.top().second;q.pop();
if(bj[x]) continue;
bj[x]=1;
for(int i=head[x];i;i=nxt[i])
{
if(d[ver[i]]>d[x]+val[i])
{
d[ver[i]]=d[x]+val[i];
q.push(mp(-d[ver[i]],ver[i]));
}
}
}
}
vector<pii> e[maxn];
int in[maxn],f[maxn];
inline void init()
{
cnt=0;
rep(i,1,n) head[i]=in[i]=f[i]=0,e[i].clear();
}
signed main()
{
T=read();
while(T--)
{
n=read(),m=read();
init();
rep(i,1,m)
{
int x=read(),y=read(),u=read(),v=read();
add(x,y,u,v);
}
dijkstra(1);
rep(x,1,n)
{
for(int i=head[x];i;i=nxt[i])
{
if(d[ver[i]]==d[x]+val[i])
{
e[x].push_back(mp(ver[i],w[i])),in[ver[i]]++;
}
}
}
queue<int> q;
rep(i,1,n) if(!in[i]) q.push(i);
while(!q.empty())
{
int x=q.front();
q.pop();
for(auto pr:e[x])
{
auto y=pr.first,v=pr.second;
in[y]--;f[y]=max(f[y],f[x]+v);
if(!in[y]) q.push(y);
}
}
printf("%lld %lld\n",d[n],f[n]);
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 254ms
memory: 47376kb
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 438209666288 250100947 25049026205784 249512452 24966236662852 0 0 0 0 0 1000000000 0 1 0 0 0 1 0 0
result:
wrong answer 6th lines differ - expected: '0 9535132634', found: '0 0'