結果
問題 | No.1365 [Cherry 1st Tune] Whose Fault? |
ユーザー | moririn2528_c |
提出日時 | 2021-01-23 05:01:29 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,989 bytes |
コンパイル時間 | 1,058 ms |
コンパイル使用メモリ | 107,044 KB |
実行使用メモリ | 8,892 KB |
最終ジャッジ日時 | 2024-06-09 09:55:08 |
合計ジャッジ時間 | 13,613 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 3 ms
6,944 KB |
testcase_08 | AC | 3 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 12 ms
6,940 KB |
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 | AC | 2 ms
6,944 KB |
testcase_44 | AC | 314 ms
8,892 KB |
testcase_45 | AC | 454 ms
6,944 KB |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:64, from main.cpp:5: In member function 'void std::vector<_Tp, _Alloc>::assign(size_type, const value_type&) [with _Tp = node; _Alloc = std::allocator<node>]', inlined from 'void union_find_tree::init()' at main.cpp:69:18, inlined from 'union_find_tree::union_find_tree(int)' at main.cpp:74:13: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h:804:23: warning: '<anonymous>' may be used uninitialized [-Wmaybe-uninitialized] 804 | { _M_fill_assign(__n, __val); } | ~~~~~~~~~~~~~~^~~~~~~~~~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:70: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/vector.tcc: In constructor 'union_find_tree::union_find_tree(int)': /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/vector.tcc:264:5: note: by argument 3 of type 'const std::vector<node>::value_type&' {aka 'const node&'} to 'void std::vector<_Tp, _Alloc>::_M_fill_assign(std::size_t, const value_type&) [with _Tp = node; _Alloc = std::allocator<node>]' declared here 264 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ main.cpp:69:26: note: '<anonymous>' declared here 69 | v1.assign(n,node()); | ^
ソースコード
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<vector> #include<cmath> #include<algorithm> #include<map> #include<queue> #include<deque> #include<iomanip> #include<tuple> #include<cassert> #include<set> #include<complex> #include<numeric> #include<functional> using namespace std; typedef long long int LL; typedef pair<int,int> P; typedef pair<LL,int> LP; const int INF=1<<30; const LL MAX=1e9+7; void array_show(int *array,int array_n,char middle=' '){ for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n')); } void array_show(LL *array,int array_n,char middle=' '){ for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n')); } void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){ if(vec_n==-1)vec_n=vec_s.size(); for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n')); } void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){ if(vec_n==-1)vec_n=vec_s.size(); for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n')); } typedef class node{ typedef long double D; public: D a,b,p; node(D _a,D _b,D _p):a(_a),b(_b),p(_p){} node(){} void connect(node n1){ b+=n1.b; a+=n1.a; p=p*n1.p/(p+n1.p); } D calc(){ return p*powl(a-b,2); } }node; class union_find_tree{ private: static constexpr int N=100005; int n; queue<int> q1; vector<int> parent; vector<int> num; typedef long double D; public: vector<node> v1; void init(){ parent.assign(n,-1); num.assign(n,1); v1.assign(n,node()); } union_find_tree(int n_init){ assert(n_init>=0); n=n_init; init(); } union_find_tree(){ n=N; init(); } int check_parent(int x){ assert(x>=0 && x<n); if(parent[x]!=-1){ q1.push(x); return check_parent(parent[x]); } int a; while(!q1.empty()){ a=q1.front(),q1.pop(); parent[a]=x; } return x; } D connect(int x,int y){ assert(x>=0 && x<n); assert(y>=0 && y<n); x=check_parent(x),y=check_parent(y); if(x==y)return 0; if(num[x]>num[y])swap(x,y); parent[x]=y; num[y]+=num[x]; D s=-v1[x].calc()-v1[y].calc(); v1[y].connect(v1[x]); return s+v1[y].calc(); } int size(int pos){ pos=check_parent(pos); return num[pos]; } }; int main(){ int n,m; int i,j,k; int a,b,c; cin>>n; union_find_tree ua(n); for(i=0;i<n;i++)cin>>ua.v1[i].a; for(i=0;i<n;i++)cin>>ua.v1[i].b; for(i=0;i<n;i++)cin>>ua.v1[i].p; long double s=0; for(i=0;i<n;i++)s+=ua.v1[i].calc(); cin>>m; cout<<fixed<<setprecision(20); for(i=0;i<m;i++){ cin>>a>>b; a--,b--; s+=ua.connect(a,b); cout<<s<<endl; } }