QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#868246#9678. 网友小 Z 的树N_z_0 2ms10184kbC++23823b2025-01-24 15:09:092025-01-24 15:09:10

Judging History

This is the latest submission verdict.

  • [2025-01-24 15:09:10]
  • Judged
  • Verdict: 0
  • Time: 2ms
  • Memory: 10184kb
  • [2025-01-24 15:09:09]
  • Submitted

answer

#include"diameter.h"
#include<bits/stdc++.h>
using namespace std;
pair<int,int>find_diameter(int,int n)
{
	if(n==1)return {1,1};
	if(n==2)return {1,2};
	if(n==3)if(in(1,2,3))return {2,3};else if(in(2,1,3))return {1,3};else return {1,2};
	int a=1,b=2,c=3,len=query(1,2,3),mn=0;
	vector<int>vlen(n+1);
	vlen[0]=1e9;
	for(int _=0;_<3;_++,swap(a,c),swap(a,b))
	{
		mn=0;
		for(int x=1;x<=n;x++)
		if(x!=b&&x!=c)
		{
			vlen[x]=query(x,b,c);
			if(vlen[x]>len)len=vlen[x],a=x;
			if(vlen[x]<=vlen[mn])mn=x;
		}
	}
	if(vlen[c]==vlen[mn])return {a,b};
	if(in(b,a,c))return {a,c};
	int l1=mn,l2,l3;
	if(in(mn,a,c))l2=query(mn,a,c),l3=2*len-l1-l2;
	else l3=query(mn,b,c),l2=2*len-l1-l3;
	if(l1==max({l1,l2,l3}))return {b,c};
	if(l2==max({l1,l2,l3}))return {a,c};
	if(l3==max({l1,l2,l3}))return {a,b};
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 10184kb

input:

1 100
25
1 3
2 18
3 8
4 18
5 14
6 22
7 18
8 10
9 11
10 12
11 25
12 16
13 11
14 17
15 17
16 25
17 2
18 20
19 18
20 12
21 1
22 17
23 14
24 1
50
1 37
2 27
3 10
4 25
5 16
6 17
7 10
8 36
9 16
10 6
11 48
12 2
13 28
14 30
15 10
16 44
17 31
18 1
19 6
20 7
21 30
22 42
23 45
24 23
25 27
26 39
27 45
28 48
29 4...

output:

WA

result:

wrong answer Wrong Answer

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #6:

0%

Subtask #8:

score: 0
Skipped

Dependency #7:

0%

Subtask #9:

score: 0
Skipped

Dependency #8:

0%

Subtask #10:

score: 0
Skipped

Dependency #9:

0%

Subtask #11:

score: 0
Skipped

Dependency #1:

0%