結果
問題 | No.1365 [Cherry 1st Tune] Whose Fault? |
ユーザー |
👑 ![]() |
提出日時 | 2021-02-06 17:30:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 498 ms / 2,000 ms |
コード長 | 456 bytes |
コンパイル時間 | 2,499 ms |
コンパイル使用メモリ | 191,828 KB |
最終ジャッジ日時 | 2025-01-18 13:38:02 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 46 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:3:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 3 | #define S(a)scanf("%d",&a); | ~~~~~^~~~~~~~~ main.cpp:6:146: note: in expansion of macro ‘S’ 6 | I N,A[1<<17],V[1<<17],u,v,g;double P[1<<17],E=0;I Z(I a){return V[a]+1?V[a]=Z(V[a]):a;}I U(I a,I b){a=Z(a);b=Z(b);return a^b?V[b]=a:-1;}I 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){g=U(u,v);E-=f(u)+f(v);A[g]+=A[u+=v-g];P[g]+=P[u];E+=f(g);}printf("%f\n",E);}return 0;} | ^ main.cpp:3:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 3 | #define S(a)scanf("%d",&a); | ~~~~~^~~~~~~~~ main.cpp:6:152: note: in expansion of macro ‘S’ 6 | I N,A[1<<17],V[1<<17],u,v,g;double P[1<<17],E=0;I Z(I a){return V[a]+1?V[a]=Z(V[a]):a;}I U(I a,I b){a=Z(a);b=Z(b);return a^b?V[b]=a:-1;}I 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){g=U(u,v);E-=f(u)+f(v);A[g]+=A[u+=v-g];P[g]+=P[u];E+=f(g);}printf("%f\n",E);}return 0;} | ^ main.cpp:3:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 3 | #define S(a)scanf("%d",&a); | ~~~~~^~~~~~~~~ main.cpp:6:161: note: in expansion of macro ‘S’ 6 | I N,A[1<<17],V[1<<17],u,v,g;double P[1<<17],E=0;I Z(I a){return V[a]+1?V[a]=Z(V[a]):a;}I U(I a,I b){a=Z(a);b=Z(b);return a^b?V[b]=a:-1;
ソースコード
#include<bits/stdc++.h> #define I int #define S(a)scanf("%d",&a); #define R for(I i=0;i<(N);i++) #define f(i)A[i]*A[i]/P[i] I N,A[1<<17],V[1<<17],u,v,g;double P[1<<17],E=0;I Z(I a){return V[a]+1?V[a]=Z(V[a]):a;}I U(I a,I b){a=Z(a);b=Z(b);return a^b?V[b]=a:-1;}I 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){g=U(u,v);E-=f(u)+f(v);A[g]+=A[u+=v-g];P[g]+=P[u];E+=f(g);}printf("%f\n",E);}return 0;}