QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#61306#4437. Link with RunningExplodingKonjacWA 870ms26272kbC++141.4kb2022-11-12 08:18:082022-11-12 08:18:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-12 08:18:12]
  • 评测
  • 测评结果:WA
  • 用时:870ms
  • 内存:26272kb
  • [2022-11-12 08:18:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using LL=long long;
using LD=long double;
using UI=unsigned int;
using ULL=unsigned long long;
using I128=__int128;
using U128=unsigned __int128;
constexpr LL INF=4e18;

int T,n,m;
vector<tuple<int,int,int>> g[100005];
struct Node
{
	LL d1,d2;
	int id;
	Node()=default;
	Node(LL _d1,LL _d2,int _i): d1(_d1),d2(_d2),id(_i){}
	inline Node upd(int v,int w1,int w2)
		{ return Node(d1+w1,d2+w2,v); }
	inline bool operator <(const Node &rhs)const
		{ return d1!=rhs.d1?d1<rhs.d1:d2>rhs.d2; }
	inline bool operator >(const Node &rhs)const
		{ return rhs<*this; }
}dis[100005];
bool vis[100005];
priority_queue<Node,vector<Node>,greater<>> q;
int main()
{
	ios::sync_with_stdio(false);
//	cin.tie(nullptr),cout.tie(nullptr);
	cin>>T;
	while(T--)
	{
		cin>>n>>m;
		for(int i=1;i<=n;i++)
		{
			g[i].clear();
			dis[i]=Node(INF,INF,i);
			vis[i]=false;
		}
		for(int i=1,u,v,w1,w2;i<=m;i++)
		{
			cin>>u>>v>>w1>>w2;
			g[u].emplace_back(v,w1,w2);
		}
		q.push(dis[1]=Node(0,0,1));
		while(!q.empty())
		{
			int u=q.top().id;
			q.pop();
			if(vis[u]) continue;
			vis[u]=true;
			for(auto &i: g[u])
			{
				int v=get<0>(i),w1=get<1>(i),w2=get<2>(i);
				Node x=dis[u].upd(v,w1,w2);
				if(!(x<dis[v])) continue;
				q.emplace(dis[v]=x);
			}
		}
		cout<<dis[n].d1<<' '<<dis[n].d2<<'\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 870ms
memory: 26272kb

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 3816491885
0 8747812611
0 1000000000
0 1
0 2
0 1
0 1

result:

wrong answer 3rd lines differ - expected: '2522027 438209666288', found: '2522027 438138599501'