QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#345409#4433. Kitten and RoombajiamengtongWA 1711ms98108kbC++14858b2024-03-06 21:59:102024-03-06 21:59:12

Judging History

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

  • [2024-03-06 21:59:12]
  • 评测
  • 测评结果:WA
  • 用时:1711ms
  • 内存:98108kb
  • [2024-03-06 21:59:10]
  • 提交

answer

#include<bits/stdc++.h>
#define M 1000005
using namespace std;
int n, c, fa[M];
double tg[M], ori[M], gt[M];
vector<int> v[M];
void dfs(int x, int ft)
{
	fa[x] = ft;
	for(auto &t : v[x])
	{
		if(t == ft) continue;
		dfs(t, x);
	}
}
void solve()
{
	scanf("%d%d", &n, &c);
	for(int i = 1; i <= n; i++) ori[i] = 0, gt[i] = 0, tg[i] = 0, v[i].clear();
	for(int i = 1, x, y; i < n; i++) scanf("%d%d", &x, &y), v[x].push_back(y), v[y].push_back(x);
	dfs(1, 0);
	ori[c] = 1;
	int m;
	scanf("%d", &m); 
	double ans = 0;
	for(int i = 1, x; i <= m; i++)
	{
		scanf("%d", &x);
		double nw = ori[x] + tg[fa[x]] - gt[x];
		gt[x] = tg[fa[x]];
		ori[x] = 0;
		ans += nw;
		nw /= v[x].size();
		ori[fa[x]] += nw;
		tg[x] += nw;
	}
	printf("%.10lf", ans);
}
int main()
{
	int T;
	scanf("%d", &T);
	while(T--) solve(); 
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1711ms
memory: 98108kb

input:

2
1000000 315562
969409 917725
324847 719085
524235 603427
576843 433171
75335 238378
266746 487233
80422 95099
594363 96140
858172 261406
958326 466109
233845 350950
863969 345645
689972 81395
395383 27274
93913 208983
523722 380358
108074 172341
130041 692304
737158 383812
752080 33646
154356 6672...

output:

5.60941734155.6105051393

result:

wrong output format Expected double, but "5.60941734155.6105051393" found