QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#197445#4437. Link with Runningyiyiyi#WA 260ms47008kbC++142.1kb2023-10-02 16:00:202023-10-02 16:00:21

Judging History

你现在查看的是最新测评结果

  • [2023-10-02 16:00:21]
  • 评测
  • 测评结果:WA
  • 用时:260ms
  • 内存:47008kb
  • [2023-10-02 16:00:20]
  • 提交

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=1e17;
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]));
			}
		}
	}
}
bool vis[maxn];
vector<pii> e[maxn];
int in[maxn],f[maxn];
inline void init()
{
	cnt=0;
	rep(i,1,n) head[i]=0,e[i].clear(),vis[i]=0;
	rep(i,1,n) f[i]=-INF;
	f[1]=0;
}
inline int dfs(int x)
{
	if(vis[x]) return f[x];
	vis[x]=1;
	for(auto pr:e[x])
	{
		auto y=pr.fi,v=pr.se;
		f[x]=max(f[x],v+dfs(y));
	}
	return f[x];
}
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[ver[i]].push_back(mp(x,w[i]));
				}
			}
		}
		f[n]=dfs(n);
		printf("%lld %lld\n",d[n],f[n]);
	}
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 260ms
memory: 47008kb

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 7302610491
0 21943348027
0 1000000000
0 1
0 2
0 1
0 1

result:

wrong answer 6th lines differ - expected: '0 9535132634', found: '0 7302610491'