QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#61335#4437. Link with RunningExplodingKonjacWA 947ms36868kbC++142.1kb2022-11-12 12:29:482022-11-12 12:29:50

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 12:29:50]
  • 评测
  • 测评结果:WA
  • 用时:947ms
  • 内存:36868kb
  • [2022-11-12 12:29:48]
  • 提交

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,eu[300005],ev[300005],ew1[300005],ew2[300005];
vector<int> g1[100005];
vector<tuple<int,int,int>> g2[100005];

int tot,top,ccnt,dfn[100005],low[100005],col[100005],st[100005];
bool vis[100005];
void tarjan(int u)
{
	dfn[u]=low[u]=++tot;
	st[++top]=u,vis[u]=false;
	for(auto &v: g1[u])
		if(!dfn[v]) tarjan(v),low[u]=min(low[u],low[v]);
		else if(vis[v]) low[u]=min(low[u],dfn[v]);
	if(low[u]==dfn[u])
	{
		int x=++ccnt,y;
		do y=st[top--],col[y]=x;
		while(y!=u);
	}
}

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];
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++)
		{
			g1[i].clear(),g2[i].clear();
			dis[i]=Node(INF,-INF,i);
			vis[i]=dfn[i]=low[i]=col[i]=0;
		}
		for(int i=1;i<=m;i++)
		{
			cin>>eu[i]>>ev[i]>>ew1[i]>>ew2[i];
			if(ew1[i] || ew2[i]) continue;
			g1[eu[i]].push_back(ev[i]);
		}
		tot=ccnt=0;
		for(int i=1;i<=n;i++) if(!dfn[i]) tarjan(i);
		for(int i=1;i<=m;i++)
		{
			int u=col[eu[i]],v=col[ev[i]];
			if(u==v) continue;
			g2[u].emplace_back(v,ew1[i],ew2[i]);
		}
		for(int i=1;i<=n;i++) vis[i]=false;
		q.push(dis[col[1]]=Node(0,0,col[1]));
		while(!q.empty())
		{
			int u=q.top().id;
			q.pop();
			if(vis[u]) continue;
			vis[u]=true;
			for(auto &i: g2[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[col[n]].d1<<' '<<dis[col[n]].d2<<'\n';
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 947ms
memory: 36868kb

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'