QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#809999#8091. Hypnocdx123456WA 116ms28972kbC++14948b2024-12-11 19:01:062024-12-11 19:01:07

Judging History

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

  • [2024-12-11 19:01:07]
  • 评测
  • 测评结果:WA
  • 用时:116ms
  • 内存:28972kb
  • [2024-12-11 19:01:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m,d[200010],f[200010];
vector<int> a[200010],v[200010];
double dp[200010];
bool cmp(int x,int y){
	return dp[x]<dp[y];
}
void solve(int x){
	if(x==n) return;
	sort(a[x].begin(),a[x].end(),cmp);
	double z=0,k=1e9,p=1;
	for(int i=0;i<a[x].size();i++){
		int y=a[x][i];
		z+=0.75*p*(dp[y]+i+1);
		p*=0.25;
		k=min(k,z+(dp[a[x][0]]+i+3)*p);
	}
	dp[x]=k;
}
int main(){
	memset(d,63,sizeof(d));
	priority_queue<pair<int,int> > q;
	int x,y;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	d[n]=0;
	q.push(make_pair(0,n));
	while(!q.empty()){
		int x=q.top().second; q.pop();
		if(f[x]) continue;
		f[x]=1;
		solve(x);
		for(int i=0;i<v[x].size();i++){
			int y=v[x][i];
			a[y].push_back(x);
			if(d[y]>d[x]+1){
				d[y]=d[x]+1;
				q.push(make_pair(-d[y],y));
			}
		}
	}
	printf("%.9lf",dp[1]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 14964kb

input:

3 3
1 2
1 3
2 3

output:

1.500000000

result:

ok found '1.500000000', expected '1.500000000', error '0.000000000'

Test #2:

score: 0
Accepted
time: 2ms
memory: 14796kb

input:

4 4
1 2
2 4
4 3
3 1

output:

2.875000000

result:

ok found '2.875000000', expected '2.875000000', error '0.000000000'

Test #3:

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

input:

2 1
2 1

output:

1.500000000

result:

ok found '1.500000000', expected '1.500000000', error '0.000000000'

Test #4:

score: 0
Accepted
time: 2ms
memory: 15020kb

input:

25 40
8 1
16 20
2 22
1 13
9 25
16 21
12 7
11 7
2 8
4 12
6 20
19 13
14 4
20 11
23 9
3 15
5 18
24 18
7 16
14 15
17 10
10 21
11 21
19 24
22 11
14 25
2 17
6 4
20 12
16 22
4 3
17 1
22 10
2 21
3 25
15 6
6 7
12 15
23 5
8 10

output:

11.990234375

result:

ok found '11.990234375', expected '11.990234375', error '0.000000000'

Test #5:

score: 0
Accepted
time: 116ms
memory: 28972kb

input:

200000 199999
197158 182193
108214 100271
143031 191662
102543 170330
22342 111905
51555 105985
38965 15493
85493 173312
117661 83898
19679 178046
145782 35268
89844 109186
74642 67192
135019 102320
48177 197815
128206 45459
11405 105702
6883 87640
51956 20707
93181 86619
40763 12411
129321 62642
14...

output:

299998.500000000

result:

ok found '299998.500000000', expected '299998.500000000', error '0.000000000'

Test #6:

score: 0
Accepted
time: 100ms
memory: 21868kb

input:

50002 199753
36147 32879
17677 29414
27179 26413
46974 8267
7863 8233
6519 33179
38082 24048
6503 24095
42138 17324
11884 41691
34548 35590
23362 49160
6130 45565
9582 2905
16457 46999
38046 24288
30879 36499
267 5375
10150 17979
19495 49811
34233 21546
1172 23094
37255 6454
45445 33820
36559 9517
2...

output:

6673.113595742

result:

ok found '6673.113595742', expected '6673.113595742', error '0.000000000'

Test #7:

score: -100
Wrong Answer
time: 3ms
memory: 15148kb

input:

3085 7273
3056 1272
1780 2634
1508 1580
85 1971
1468 913
2765 185
1345 1396
392 1019
2554 2458
1974 1575
2663 2388
569 1644
281 385
401 575
1580 2813
415 1585
1189 1170
1658 3081
9 1464
2819 1489
1422 1817
2726 1143
1205 452
991 722
1879 3027
933 683
1808 2156
221 2648
2488 2931
1255 1454
1317 2097
...

output:

709.500000000

result:

wrong answer 1st numbers differ - expected: '709.3968964', found: '709.5000000', error = '0.0001453'