結果

問題 No.1365 [Cherry 1st Tune] Whose Fault?
ユーザー 👑 NachiaNachia
提出日時 2021-02-06 17:08:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 2,171 ms
コンパイル使用メモリ 202,280 KB
実行使用メモリ 4,720 KB
最終ジャッジ日時 2023-09-16 02:37:43
合計ジャッジ時間 17,994 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 20 ms
4,376 KB
testcase_14 AC 15 ms
4,376 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 12 ms
4,376 KB
testcase_18 AC 8 ms
4,380 KB
testcase_19 AC 20 ms
4,376 KB
testcase_20 AC 13 ms
4,380 KB
testcase_21 AC 18 ms
4,376 KB
testcase_22 AC 14 ms
4,380 KB
testcase_23 AC 46 ms
4,376 KB
testcase_24 AC 96 ms
4,380 KB
testcase_25 AC 184 ms
4,380 KB
testcase_26 AC 126 ms
4,376 KB
testcase_27 AC 144 ms
4,380 KB
testcase_28 AC 61 ms
4,380 KB
testcase_29 AC 54 ms
4,380 KB
testcase_30 AC 225 ms
4,492 KB
testcase_31 AC 203 ms
4,560 KB
testcase_32 AC 115 ms
4,412 KB
testcase_33 AC 176 ms
4,380 KB
testcase_34 AC 139 ms
4,384 KB
testcase_35 AC 85 ms
4,380 KB
testcase_36 AC 171 ms
4,640 KB
testcase_37 AC 37 ms
4,380 KB
testcase_38 AC 50 ms
4,384 KB
testcase_39 AC 211 ms
4,380 KB
testcase_40 AC 208 ms
4,384 KB
testcase_41 AC 164 ms
4,452 KB
testcase_42 AC 141 ms
4,380 KB
testcase_43 AC 2 ms
4,384 KB
testcase_44 AC 67 ms
4,720 KB
testcase_45 AC 77 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define I int
#define S(a) scanf("%d",&a);
#define R for(I i=0;i<(N);i++)

struct D{vector<I> V;D(I n){V.assign(n,-1);}I r(I a){return(V[a]<0)?a:(V[a]=r(V[a]));}I u(I a,I b){a=r(a);b=r(b);return(a==b)?-1:(V[b]=a);}};
I N,A[100000],u,v,g;
double P[100000],ans=0.0;
double f(I i){return A[i]*A[i]/P[i];}
I main(){
S(N)D G(N);R S(A[i]);R {S(u);A[i]-=u;}R {S(u);P[i]=1./u;ans+=f(i);}S(N)
R{S(u)S(v)u=G.r(u-1);v=G.r(v-1);if(u!=v){g=G.u(u,v);ans-=f(u)+f(v);A[g]+=A[u+v-g];P[g]+=P[u+v-g];ans+=f(g);}printf("%.4f\n",ans);}
return 0;}
0