QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#197299#4437. Link with Runningyiyiyi#WA 303ms32960kbC++141.4kb2023-10-02 14:17:242023-10-02 14:17:24

Judging History

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

  • [2023-10-02 14:17:24]
  • 评测
  • 测评结果:WA
  • 用时:303ms
  • 内存:32960kb
  • [2023-10-02 14:17:24]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define inf 0x3f3f3f3f
#define re register
#define N 301200
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
struct edge{
	int to;pii dis;int next;
	friend bool operator <(edge a,edge b){
		return a.dis>b.dis;
	}
}e[N<<1];
inline int read(){
	int x=0,w=0;char ch=getchar();
	while (!isdigit(ch))w|=ch=='-',ch=getchar();
	while (isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return w?-x:x;
}
priority_queue<edge>q;
int n,m,s,vis[N],cnt,head[N];
pii dis[N];
void add(int u,int v,int d,int w){
	e[++cnt].to=v;
	e[cnt].dis={d,-w};
	e[cnt].next=head[u];
	head[u]=cnt;
}
pii operator +(pii a,pii b){
	return {a.fi+b.fi,a.se+b.se};
}
void dij(){
	for (int i=1;i<=n;++i)dis[i]={inf,0},vis[i]=0;
	dis[1]={0,0};
	q.push((edge){1,{0,0}});
	while (!q.empty()){
		int u=q.top().to;q.pop();
		if(vis[u])continue;
		vis[u]=1;
		for (int i=head[u];i;i=e[i].next){
			int v=e[i].to;
			if (dis[v]>dis[u]+e[i].dis){
				dis[v]=dis[u]+e[i].dis;
				if (!vis[v])q.push((edge){v,dis[v]});
			}
		}
	}
}
void solve(){
	n=read(),m=read();
	cnt=0;
	for (int i=1;i<=n;++i)head[i]=0;
	for (int i=1;i<=m;++i){
		int u=read(),v=read(),d=read(),w=read();
		add(u,v,d,w);
	}
	dij();
	printf("%lld %lld\n",dis[n].fi,-dis[n].se); 
}
signed main(){
	int T=read();
	while (T--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 303ms
memory: 32960kb

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:

1061109567 0
2529348 325344428756
2522027 438138599501
250100947 25049026205784
249512452 24966236662852
0 3816491885
0 8747812611
0 1000000000
0 1
0 2
0 1
0 1

result:

wrong answer 1st lines differ - expected: '5927443549 11285847934', found: '1061109567 0'