QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#810083#8091. Hypnocdx123456WA 68ms20316kbC++14943b2024-12-11 19:37:202024-12-11 19:37:29

Judging History

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

  • [2024-12-11 19:37:29]
  • 评测
  • 测评结果:WA
  • 用时:68ms
  • 内存:20316kb
  • [2024-12-11 19:37:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define double float
int n,m,f[200010],sum[200010],S[200010],T[200010];
vector<int> v[200010];
double d[200010],Z[200010],P[200010];
void solve(int x){
	if(sum[x]>30) return;
	Z[x]+=0.75*P[x]*(d[T[x]]+sum[x]);
	P[x]*=0.25;
	d[x]=min(d[x],Z[x]+(d[S[x]]+sum[x]+2)*P[x]);
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	priority_queue<pair<double,int> > q;
	int x,y;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		d[i]=1e9;
		P[i]=1;
	}
	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;
		for(int i=0;i<v[x].size();i++){
			int y=v[x][i];
			if(f[y]) continue;
			sum[y]++;
			if(sum[y]==1) S[y]=x;
			T[y]=x;
			solve(y);
			q.push(make_pair(-d[y],y));
		}
	}
	printf("%.9lf",d[1]);
	return 0;
}

詳細信息

Test #1:

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

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: 1ms
memory: 9892kb

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: 1ms
memory: 9860kb

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: 1ms
memory: 10032kb

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: 68ms
memory: 20316kb

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: -100
Wrong Answer
time: 50ms
memory: 16172kb

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.009277344

result:

wrong answer 1st numbers differ - expected: '6673.1135957', found: '6673.0092773', error = '0.0000156'