QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#61311#4437. Link with RunningExplodingKonjacTL 0ms0kbC++141.3kb2022-11-12 09:19:542022-11-12 09:19:56

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 09:19:56]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2022-11-12 09:19:54]
  • 提交

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 inq[100005];
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);
			inq[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);
		}
		queue<int> q;
		q.push(1),dis[1]=Node(0,0,1);
		while(!q.empty())
		{
			int u=q.front();
			q.pop(),inq[u]=false;
			for(auto &i: g[u])
			{
				int v=get<0>(i),w1=get<1>(i),w2=get<2>(i);
				if(!(dis[u].upd(v,w1,w2)<dis[v])) continue;
				dis[v]=dis[u].upd(v,w1,w2);
				if(!inq[v]) q.push(v),inq[v]=true;
			}
		}
		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
Time Limit Exceeded

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

result: