結果

問題 No.1365 [Cherry 1st Tune] Whose Fault?
ユーザー 👑 NachiaNachia
提出日時 2021-02-06 17:39:38
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 243 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 2,114 ms
コンパイル使用メモリ 197,680 KB
実行使用メモリ 5,040 KB
最終ジャッジ日時 2023-09-16 03:40:57
合計ジャッジ時間 18,577 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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,376 KB
testcase_04 AC 1 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,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 22 ms
4,376 KB
testcase_14 AC 15 ms
4,380 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 13 ms
4,380 KB
testcase_18 AC 8 ms
4,380 KB
testcase_19 AC 21 ms
4,380 KB
testcase_20 AC 13 ms
4,380 KB
testcase_21 AC 19 ms
4,384 KB
testcase_22 AC 15 ms
4,376 KB
testcase_23 AC 49 ms
4,380 KB
testcase_24 AC 101 ms
4,400 KB
testcase_25 AC 196 ms
4,552 KB
testcase_26 AC 136 ms
4,672 KB
testcase_27 AC 156 ms
4,380 KB
testcase_28 AC 64 ms
4,380 KB
testcase_29 AC 56 ms
4,376 KB
testcase_30 AC 243 ms
4,672 KB
testcase_31 AC 219 ms
4,976 KB
testcase_32 AC 124 ms
4,616 KB
testcase_33 AC 187 ms
4,376 KB
testcase_34 AC 150 ms
4,384 KB
testcase_35 AC 90 ms
4,540 KB
testcase_36 AC 182 ms
4,872 KB
testcase_37 AC 40 ms
4,384 KB
testcase_38 AC 53 ms
4,660 KB
testcase_39 AC 225 ms
4,520 KB
testcase_40 AC 222 ms
4,420 KB
testcase_41 AC 171 ms
4,700 KB
testcase_42 AC 152 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 68 ms
5,040 KB
testcase_45 AC 79 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define S(a)scanf("%d",&a);
#define R for(int i=0;i<(N);i++)
#define f(i)A[i]*A[i]/P[i]
int N,A[1<<17],V[1<<17],u,v;double P[1<<17],E=0;int Z(int a){return V[a]+1?V[a]=Z(V[a]):a;}int main(){S(N)R S(A[i])R{S(u)A[i]-=u;V[i]=-1;}R{S(u)P[i]=1./u;E+=f(i);}S(N)R{S(u)S(v)u=Z(u-1);v=Z(v-1);if(u^v){V[v]=u;E-=f(u)+f(v);A[u]+=A[v];P[u]+=P[v];E+=f(u);}printf("%f\n",E);}return 0;}
0