QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#377888#5054. City BrainInfinityNS#WA 369ms102780kbC++141.6kb2024-04-05 19:16:002024-04-05 19:16:01

Judging History

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

  • [2024-04-05 19:16:01]
  • 评测
  • 测评结果:WA
  • 用时:369ms
  • 内存:102780kb
  • [2024-04-05 19:16:00]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ldb double
#define pb push_back

const int N=5050;
vector<int> E[N];
const int inf=1e9+7;
int best[N],dist[N][N];

ldb Calc(int x,int k){
	if(x==0)return 0;
	int val=k/x+1;
	int ost=k%x;
	return (ldb)1/val*(x-ost)+(ldb)1/(val+1)*ost;
}
ldb Calc(int x,int kx,int y,int ky){
	return 2*Calc(x,kx)+Calc(y,ky);
}
int main(){
	int n,m,k;
	scanf("%i %i %i",&n,&m,&k);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%i %i",&u,&v);
		E[u].pb(v);
		E[v].pb(u);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dist[i][j]=inf;
		}
		dist[i][i]=0;
		queue<int> q;
		q.push(i);
		while(q.size()){
			int u=q.front();
			q.pop();
			for(int v:E[u]){
				if(dist[i][v]>dist[i][u]+1){
					dist[i][v]=dist[i][u]+1;
					q.push(v);
				}
			}
		}
	}
	int s1,t1,s2,t2;
	scanf("%i %i %i %i",&s1,&t1,&s2,&t2);
	best[0]=dist[s1][t1]+dist[s2][t2];
	for(int i=1;i<n;i++)best[i]=inf;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j!=i && dist[i][j]!=inf){
				int now=min(dist[s1][i]+dist[s2][i]+dist[t1][j]+dist[t2][j],dist[s1][i]+dist[s2][j]+dist[t1][j]+dist[t2][i]);
				best[dist[i][j]]=min(best[dist[i][j]],now);
			}
		}
	}
	ldb ans=best[0];
	for(int i=0;i<n;i++){
		if(best[i]<inf){
			int bot=0,top=k-1,sol=k;
			while(bot<=top){
				int mid=bot+top>>1;
				ldb ans1=Calc(i,mid,best[i],k-mid);
				ldb ans2=Calc(i,mid+1,best[i],k-mid-1);
				if(ans1<ans2){
					top=mid-1;
					sol=mid;
				}else{
					bot=mid+1;
				}
			}
			ans=min(ans,Calc(i,sol,best[i],k-sol));
		}
	}
	printf("%.12lf\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4096kb

input:

6 5 1
1 2
3 2
2 4
4 5
4 6
1 5 3 6

output:

5.000000000000

result:

ok found '5.000000000', expected '5.000000000', error '0.000000000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 4156kb

input:

1 0 100
1 1 1 1

output:

0.000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #3:

score: 0
Accepted
time: 1ms
memory: 4216kb

input:

4 2 3
1 2
3 4
1 2 3 4

output:

0.833333333333

result:

ok found '0.833333333', expected '0.833333333', error '0.000000000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 4024kb

input:

6 5 1
1 2
3 2
2 4
4 5
4 6
1 5 6 3

output:

5.000000000000

result:

ok found '5.000000000', expected '5.000000000', error '0.000000000'

Test #5:

score: 0
Accepted
time: 180ms
memory: 102696kb

input:

5000 4999 1000000000
1 2
1 3
1 4
1 5
6 2
7 3
8 4
9 5
10 6
11 7
12 8
13 9
14 10
15 11
16 12
17 13
18 14
19 15
20 16
21 17
22 18
23 19
24 20
25 21
26 22
27 23
28 24
29 25
30 26
31 27
32 28
33 29
34 30
35 31
36 32
37 33
38 34
39 35
40 36
41 37
42 38
43 39
44 40
45 41
46 42
47 43
48 44
49 45
50 46
51 47...

output:

0.024989876076

result:

ok found '0.024989876', expected '0.024989876', error '0.000000000'

Test #6:

score: 0
Accepted
time: 1ms
memory: 4236kb

input:

10 9 305097549
2 1
8 9
6 7
5 4
8 7
4 3
2 3
9 10
6 5
4 3 2 1

output:

0.000000013111

result:

ok found '0.000000013', expected '0.000000013', error '0.000000000'

Test #7:

score: 0
Accepted
time: 1ms
memory: 4008kb

input:

10 9 9
4 2
3 6
8 6
2 1
7 9
5 2
2 3
10 9
7 4
8 7 9 5

output:

3.833333333333

result:

ok found '3.833333333', expected '3.833333333', error '0.000000000'

Test #8:

score: 0
Accepted
time: 1ms
memory: 4236kb

input:

10 9 19
5 2
4 1
2 1
6 5
10 8
8 1
9 3
7 6
1 3
7 7 6 4

output:

0.700000000000

result:

ok found '0.700000000', expected '0.700000000', error '0.000000000'

Test #9:

score: 0
Accepted
time: 0ms
memory: 6208kb

input:

100 99 149
82 77
11 14
99 94
29 24
41 31
52 57
64 73
42 32
85 84
88 86
54 59
75 66
38 28
92 90
9 19
60 61
24 19
24 31
21 18
38 47
67 74
79 89
64 66
34 29
23 16
87 83
11 16
2 4
10 11
76 77
36 32
18 22
71 72
79 77
97 96
47 48
43 34
63 55
51 45
91 94
3 1
31 39
41 44
51 58
6 10
48 54
74 76
7 15
18 13
32...

output:

1.805982905983

result:

ok found '1.805982906', expected '1.805982906', error '0.000000000'

Test #10:

score: 0
Accepted
time: 1ms
memory: 6108kb

input:

100 99 126
23 98
27 75
2 7
81 83
10 13
99 3
10 7
70 56
28 16
3 15
18 16
51 55
1 33
6 3
53 61
3 1
68 76
68 85
26 79
40 86
28 37
25 16
12 14
23 48
22 3
66 96
16 39
41 90
69 100
97 89
37 84
51 37
32 25
36 14
35 21
67 20
7 27
23 31
4 23
32 34
44 1
66 23
95 70
42 73
26 7
19 38
93 58
39 88
2 65
1 12
81 2
...

output:

0.272727272727

result:

ok found '0.272727273', expected '0.272727273', error '0.000000000'

Test #11:

score: 0
Accepted
time: 268ms
memory: 102724kb

input:

5000 4999 7363
4100 4099
2570 2569
494 493
608 609
3424 3423
1771 1770
4935 4934
1536 1537
2704 2703
2429 2428
4048 4049
2708 2709
3982 3981
1866 1867
1779 1780
1491 1490
3719 3720
3960 3959
1515 1516
2157 2158
3798 3799
4624 4625
2626 2627
4882 4883
2769 2770
4999 4998
514 513
3236 3237
3424 3425
2...

output:

365.900000000000

result:

ok found '365.900000000', expected '365.900000000', error '0.000000000'

Test #12:

score: 0
Accepted
time: 369ms
memory: 102780kb

input:

5000 4999 1713
4590 4518
4868 4954
2977 2986
2091 2190
458 540
1668 1738
2670 2760
371 441
4778 4800
4282 4347
534 557
1560 1498
2444 2430
4602 4520
1361 1457
4934 4918
963 984
2305 2274
798 842
4150 4174
1102 1038
1264 1234
115 175
4994 4901
3375 3459
530 468
1517 1480
1080 1150
4637 4568
2456 2414...

output:

6.626118925831

result:

ok found '6.626118926', expected '6.626118926', error '0.000000000'

Test #13:

score: 0
Accepted
time: 345ms
memory: 102732kb

input:

5000 4999 603835068
223 714
1868 220
1010 1047
1227 21
745 933
1281 1894
891 1005
4601 158
880 44
894 310
1418 4453
819 2380
4555 2795
632 4515
321 2239
100 1280
258 1374
827 616
4922 3842
3482 4721
1764 2675
1133 225
3144 124
3169 683
920 2958
370 534
72 255
648 3923
3013 852
977 284
2880 3728
53 4...

output:

0.000001490473

result:

ok found '0.000001490', expected '0.000001490', error '0.000000000'

Test #14:

score: 0
Accepted
time: 1ms
memory: 4220kb

input:

10 10 629318717
4 9
2 10
8 7
7 6
3 2
9 10
4 9
8 10
3 4
1 6
8 4 4 7

output:

0.000000043675

result:

ok found '0.000000044', expected '0.000000044', error '0.000000000'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3936kb

input:

10 20 857
1 9
5 8
3 9
8 9
4 2
9 5
2 3
7 6
5 10
4 1
9 3
7 4
1 3
5 6
3 1
7 9
6 3
8 6
5 4
8 7
2 2 1 6

output:

0.004656583726

result:

ok found '0.004656584', expected '0.004656584', error '0.000000000'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3996kb

input:

10 100 884099588
8 6
3 8
3 6
8 3
2 6
7 4
2 1
7 4
5 1
7 3
9 10
3 1
10 5
5 6
5 1
9 10
4 1
10 4
8 10
6 3
10 7
7 3
9 10
7 10
2 10
3 2
3 10
8 3
10 5
5 10
9 4
2 9
3 7
2 5
10 2
9 10
8 5
10 7
6 7
4 7
1 3
7 9
10 6
1 8
6 3
1 4
1 9
2 7
5 3
7 4
6 2
1 4
6 10
6 7
10 1
8 10
4 9
7 8
10 4
9 3
3 8
4 10
6 9
10 8
5 9
5...

output:

0.000000004524

result:

ok found '0.000000005', expected '0.000000005', error '0.000000000'

Test #17:

score: -100
Wrong Answer
time: 1ms
memory: 6344kb

input:

100 100 730
42 80
21 28
34 48
2 21
38 48
23 61
66 5
5 86
69 6
69 82
9 63
69 50
63 54
62 8
21 42
16 97
41 86
24 51
44 95
11 97
10 32
89 8
40 19
26 12
23 46
28 89
82 43
72 96
24 25
41 53
56 53
80 70
42 44
27 32
60 50
61 100
73 36
90 53
97 59
5 79
56 78
78 95
39 80
74 20
63 46
45 7
80 91
37 5
21 49
65 ...

output:

-294967631.500000000000

result:

wrong answer 1st numbers differ - expected: '0.0340136', found: '-294967631.5000000', error = '294967631.5340136'