QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#317306#7118. Closing TimeRandom_Code#0 44ms253800kbC++175.4kb2024-01-28 20:01:242024-01-28 20:01:24

Judging History

你现在查看的是测评时间为 2024-01-28 20:01:24 的历史记录

  • [2024-04-28 08:34:03]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:62ms
  • 内存:253280kb
  • [2024-01-28 20:01:24]
  • 评测
  • 测评结果:0
  • 用时:44ms
  • 内存:253800kb
  • [2024-01-28 20:01:24]
  • 提交

answer

//ANMHLIJKTJIY!
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#include "closing.h"
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define F first
#define S second
#define ll long long
#define N 200010
#define M 550010
using namespace std;
ll nxtx[3][3]={{0,-1,-1},{1,-1,-1},{1,1,2}},nxty[3][3]={{0,1,1},{0,-1,1},{-1,-1,2}};
ll n,sx,sy,lim,dis[N][2],fa[N],bel[N],mn[M][3][3][2];
bool vis[N];
vector<pair<ll,ll> > vt[N];
vector<ll> nds[N],seq,dp[M][3][3][2];
void predfs(ll x,ll lst,ll id,ll d)
{
	ll i;
	dis[x][id]=d;
	fa[x]=lst;
	for(i=0;i<vt[x].size();i++)
	{
		if(vt[x][i].F!=lst)
		{
			predfs(vt[x][i].F,x,id,d+vt[x][i].S);
		}
	}
	return;
}
void dfsbel(ll x,ll lst,ll tp)
{
	if(vis[x])
	{
		tp=x;
	}
	bel[x]=tp;
	nds[tp].push_back(x);
	ll i;
	for(i=0;i<vt[x].size();i++)
	{
		if(vt[x][i].F!=lst)
		{
			dfsbel(vt[x][i].F,x,tp);
		}
	}
	return;
}
void Merge(ll p,ll p0,ll p1,ll p2,ll u,ll u0,ll u1,ll u2,ll v,ll v0,ll v1,ll v2)
{
	ll i,j,lo=(mn[u][u0][u1][u2]+mn[v][v0][v1][v2]-mn[p][p0][p1][p2])/2;
	for(i=0;i<dp[u][u0][u1][u2].size();i++)
	{
		for(j=0;j<dp[v][v0][v1][v2].size();j++)
		{
			while(dp[p][p0][p1][p2].size()<=lo+i+j)
			{
				dp[p][p0][p1][p2].push_back(LINF);
			}
			dp[p][p0][p1][p2][lo+i+j]=min(dp[p][p0][p1][p2][lo+i+j],dp[u][u0][u1][u2][i]+dp[v][v0][v1][v2][j]);
		}
	}
	return;
}
void solve(ll x,ll l,ll r)
{
	ll i,j,k,d,p,q;
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			for(k=0;k<2;k++)
			{
				dp[x][i][j][k].clear();
				mn[x][i][j][k]=INF;
			}
		}
	}
	if(l==r)
	{
		ll u=seq[l];
		dp[x][0][0][0].push_back(0);
		mn[x][0][0][0]=0;
		vector<ll> allv;
		for(i=0;i<nds[u].size();i++)
		{
			allv.push_back(dis[nds[u][i]][0]);
		}
		sort(allv.begin(),allv.end());
		mn[x][2][0][0]=2;
		mn[x][2][0][1]=1;
		ll v=0;
		for(i=0;i<allv.size();i++)
		{
			v+=allv[i];
			if(i&1)
			{
				dp[x][2][0][0].push_back(v);
			}
			else
			{
				dp[x][2][0][1].push_back(v);
			}
		}
		for(i=0;i<nds[u].size();i++)
		{
			allv[i]=dis[nds[u][i]][1];
		}
		sort(allv.begin(),allv.end());
		mn[x][0][2][0]=2;
		mn[x][0][2][1]=1;
		v=0;
		for(i=0;i<allv.size();i++)
		{
			v+=allv[i];
			if(i&1)
			{
				dp[x][0][2][0].push_back(v);
			}
			else
			{
				dp[x][0][2][1].push_back(v);
			}
		}
		ll delta=abs(dis[u][0]-dis[u][1]);
		for(i=0;i<nds[u].size();i++)
		{
			allv[i]=min(dis[nds[u][i]][0],dis[nds[u][i]][1]);
		}
		sort(allv.begin(),allv.end());
		mn[x][2][2][0]=2;
		mn[x][2][2][1]=3;
		dp[x][2][2][0].push_back(v=allv[0]+delta);
		for(i=1;i<allv.size()&&allv[i]<delta;i++)
		{
			v+=allv[i];
			dp[x][2][2][i&1].push_back(v);
		}
		for(j=1;j<i;j++)
		{
			v+=delta;
			dp[x][2][2][(i+j)&1].push_back(v);
		}
		for(;i<allv.size();i++)
		{
			v+=allv[i];
			dp[x][2][2][1].push_back(v);
			v+=delta;
			dp[x][2][2][0].push_back(v);
		}
//		cout<<l<<"~"<<r<<":\n";
//		for(i=0;i<3;i++)
//		{
//			for(j=0;j<3;j++)
//			{
//				for(k=0;k<2;k++)
//				{
//					cout<<i<<","<<j<<","<<k<<": "<<mn[x][i][j][k]<<": ";
//					for(d=0;d<dp[x][i][j][k].size();d++)
//					{
//						cout<<dp[x][i][j][k][d]<<" , ";
//					}
//					puts("");
//				}
//			}
//		}
		return;
	}
	ll mid=(l+r)>>1,a=x<<1;
	solve(a,l,mid);
	solve(a|1,mid+1,r);
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			for(k=0;k<2;k++)
			{
				for(d=0;d<3;d++)
				{
					for(p=0;p<3;p++)
					{
						if(nxtx[i][d]==-1||nxty[j][p]==-1)
						{
							continue;
						}
						for(q=0;q<2;q++)
						{
							mn[x][nxtx[i][d]][nxty[j][p]][k^q]=min(mn[x][nxtx[i][d]][nxty[j][p]][k^q],mn[a][i][j][k]+mn[a|1][d][p][q]);
						}
					}
				}
			}
		}
	}
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			for(k=0;k<2;k++)
			{
				for(d=0;d<3;d++)
				{
					for(p=0;p<3;p++)
					{
						if(nxtx[i][d]==-1||nxty[j][p]==-1)
						{
							continue;
						}
						for(q=0;q<2;q++)
						{
							Merge(x,nxtx[i][d],nxty[j][p],k^q,a,i,j,k,a|1,d,p,q);
						}
					}
				}
			}
		}
	}
//	cout<<l<<"~"<<r<<":\n";
//	for(i=0;i<3;i++)
//	{
//		for(j=0;j<3;j++)
//		{
//			for(k=0;k<2;k++)
//			{
//				cout<<i<<","<<j<<","<<k<<": "<<mn[x][i][j][k]<<": ";
//				for(d=0;d<dp[x][i][j][k].size();d++)
//				{
//					cout<<dp[x][i][j][k][d]<<" , ";
//				}
//				puts("");
//			}
//		}
//	}
	return;
}
int max_score(int _n,int _x,int _y,ll _k,vector<int> U,vector<int> V,vector<int> W)
{
	ll i,j,k;
	n=_n;
	sx=_x,sy=_y,lim=_k;
	for(i=0;i<n;i++)
	{
		nds[i].clear();
		vis[i]=false;
		vt[i].clear();
	}
	for(i=0;i<U.size();i++)
	{
		vt[U[i]].push_back(make_pair(V[i],W[i]));
		vt[V[i]].push_back(make_pair(U[i],W[i]));
	}
	predfs(sx,-1,0,0);
	predfs(sy,-1,1,0);
	seq.clear();
	for(i=sx;i>=0;i=fa[i])
	{
		seq.push_back(i);
		vis[i]=true;
	}
	dfsbel(sx,-1,sx);
	solve(1,0,seq.size()-1);
	ll ret=0;
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
		{
			for(k=0;k<2;k++)
			{
				ll p=lower_bound(dp[1][i][j][k].begin(),dp[1][i][j][k].end(),lim+1)-dp[1][i][j][k].begin()-1;
				if(p>=0)
				{
					ret=max(ret,p*2+mn[1][i][j][k]);
				}
			}
		}
	}
	return ret;
}

详细

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
200000 31011 61157 8517583098
31011 129396 964383
1655 129396 331139
1655 191487 566483
110385 191487 865248
43212 110385 542661
43212 81682 13766
81682 91774 546589
91774 124706 780638
124706 175650 118706
10421 175650 615314
10421 151953 436270
140430 151...

output:


result:


Subtask #2:

score: 0
Wrong Answer

Test #4:

score: 0
Wrong Answer
time: 35ms
memory: 250352kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
50 23 25 382806473
0 1 375710
1 2 898637
2 3 10402
3 4 536577
4 5 385023
5 6 71075
6 7 543368
7 8 301497
8 9 174394
9 10 711312
10 11 923006
11 12 675532
12 13 838667
13 14 565729
14 15 979816
15 16 862618
16 17 576015
17 18 177751
18 19 306989
19 20 881492...

output:

081ce3c351cbf526b37954b9ad30f2b531a7585c
OK
98

result:

wrong answer 1st lines differ - on the 1st token, expected: '96', found: '98'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Wrong Answer

Test #36:

score: 9
Accepted
time: 40ms
memory: 253668kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
4 0 1 9
0 2 2
1 2 3
2 3 3

output:

081ce3c351cbf526b37954b9ad30f2b531a7585c
OK
6

result:

ok 

Test #37:

score: 0
Accepted
time: 43ms
memory: 253672kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
4 0 1 8
0 2 2
1 2 3
2 3 100

output:

081ce3c351cbf526b37954b9ad30f2b531a7585c
OK
5

result:

ok 

Test #38:

score: 0
Accepted
time: 44ms
memory: 253800kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
8 0 4 84
0 1 1
1 2 29
2 3 29
3 4 1
4 5 20
2 6 20
3 7 1

output:

081ce3c351cbf526b37954b9ad30f2b531a7585c
OK
9

result:

ok 

Test #39:

score: 0
Accepted
time: 40ms
memory: 253680kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
18 14 15 221112
8 10 15984
3 8 2664
6 10 5328
9 10 13320
5 10 23976
1 10 13320
3 4 5328
3 7 26640
3 11 23976
4 15 23976
6 17 18648
12 17 5328
11 13 13320
0 11 7992
15 16 5328
2 16 5328
13 14 2664

output:

081ce3c351cbf526b37954b9ad30f2b531a7585c
OK
14

result:

ok 

Test #40:

score: 0
Accepted
time: 40ms
memory: 252248kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
19 3 9 11232111
13 14 174955
0 13 69982
10 14 209946
14 15 209946
12 14 104973
0 11 314919
0 3 314919
0 7 139964
5 10 209946
10 16 69982
4 10 104973
9 11 279928
9 17 349910
1 4 104973
3 18 209946
6 18 174955
7 8 314919
2 7 104973

output:

081ce3c351cbf526b37954b9ad30f2b531a7585c
OK
28

result:

ok 

Test #41:

score: 0
Accepted
time: 31ms
memory: 250728kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
15 5 7 155966
1 4 964448
5 11 996819
9 10 330180
5 6 987448
11 12 704605
0 5 155967
8 14 596631
10 11 923917
0 14 560902
4 13 49411
1 7 856694
1 12 755799
2 14 488208
3 13 990480

output:

081ce3c351cbf526b37954b9ad30f2b531a7585c
OK
2

result:

ok 

Test #42:

score: 0
Accepted
time: 24ms
memory: 252236kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
20 4 7 40726445
15 18 841797
9 16 909512
0 7 39919
8 19 78725
6 17 661904
7 14 426400
17 18 664669
7 13 917960
4 14 821652
4 11 274656
1 12 937782
10 19 129031
12 13 504353
5 11 502915
3 8 264525
2 19 358409
12 18 578659
16 19 696491
3 17 175157

output:

081ce3c351cbf526b37954b9ad30f2b531a7585c
OK
30

result:

ok 

Test #43:

score: -9
Wrong Answer
time: 43ms
memory: 250716kb

input:

cc61ad56a4797fb3f5c9529f73ce6fcedd85669b
1
19 1 8 758761123780644886
3 18 947982
12 13 415218
3 15 890432
11 17 808801
2 8 726510
7 12 752493
8 17 328133
6 7 465830
8 14 126540
9 18 443041
1 7 605214
4 11 243452
9 10 106626
3 7 498126
1 4 39081
0 2 861168
5 15 69635
3 16 223395

output:

081ce3c351cbf526b37954b9ad30f2b531a7585c
OK
39

result:

wrong answer 1st lines differ - on the 1st token, expected: '38', found: '39'

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Skipped

Dependency #4:

0%

Subtask #9:

score: 0
Skipped

Dependency #1:

0%