結果

問題 No.1365 [Cherry 1st Tune] Whose Fault?
ユーザー publflpublfl
提出日時 2021-01-22 21:42:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 993 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 33,056 KB
実行使用メモリ 4,932 KB
最終ジャッジ日時 2023-08-28 11:21:43
合計ジャッジ時間 4,361 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 95 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int next[100010];
int find(int k)
{
	if(next[k]==k) return k;
	else return next[k] = find(next[k]);
}

int A[100010],B[100010];
double P[100010];

int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a;i++) scanf("%d",&A[i]);
	for(int i=1;i<=a;i++) scanf("%d",&B[i]);
	for(int i=1;i<=a;i++)
	{
		int c;
		scanf("%d",&c);
		P[i] = (double)1/(2*c);
	}
	
	double sum = 0;
	for(int i=1;i<=a;i++) next[i] = i;
	for(int i=1;i<=a;i++)
	{
		double lambda = (A[i]-B[i])/P[i];
		sum += (lambda*lambda*P[i])/2;
	}
	
	int b;
	scanf("%d",&b);
	for(int i=1;i<=b;i++)
	{
		int c,d;
		scanf("%d%d",&c,&d);
		c = find(c);
		d = find(d);
		if(c!=d)
		{
			double lambda;
			lambda = (A[c]-B[c])/(P[c]);
			sum -= (lambda * lambda * P[c])/2;
			lambda = (A[d]-B[d])/(P[d]);
			sum -= (lambda * lambda * P[d])/2;
			
			next[c] = d;
			A[d] += A[c];
			B[d] += B[c];
			P[d] += P[c];
			
			lambda = (A[d]-B[d])/(P[d]);
			sum += (lambda * lambda * P[d])/2;
		}
		printf("%.12lf\n",sum);
	}
}
0