結果
問題 | No.1928 Make a Binary Tree |
ユーザー | harurun |
提出日時 | 2021-12-01 02:00:47 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 997 bytes |
コンパイル時間 | 1,223 ms |
コンパイル使用メモリ | 102,540 KB |
実行使用メモリ | 34,080 KB |
最終ジャッジ日時 | 2024-04-23 22:02:15 |
合計ジャッジ時間 | 12,986 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 2 ms
6,944 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 | AC | 214 ms
19,908 KB |
testcase_36 | AC | 222 ms
26,660 KB |
testcase_37 | WA | - |
testcase_38 | RE | - |
testcase_39 | AC | 260 ms
26,380 KB |
testcase_40 | AC | 257 ms
26,380 KB |
testcase_41 | AC | 246 ms
26,256 KB |
testcase_42 | AC | 245 ms
26,248 KB |
testcase_43 | AC | 258 ms
26,376 KB |
testcase_44 | AC | 254 ms
26,248 KB |
testcase_45 | AC | 262 ms
26,248 KB |
testcase_46 | AC | 256 ms
26,256 KB |
testcase_47 | AC | 253 ms
26,380 KB |
testcase_48 | AC | 248 ms
26,380 KB |
testcase_49 | AC | 232 ms
34,080 KB |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | AC | 219 ms
26,140 KB |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
ソースコード
#include <iostream> #include <vector> #include <utility> #include <atcoder/segtree> using namespace atcoder; using namespace std; vector<vector<int>> Graph; vector<bool> checked; pair<int,int> op(pair<int,int> a,pair<int,int> b){ return a>b?a:b; } pair<int,int> e(){ return make_pair(-1,-1); } segtree<pair<int,int>,op,e> seg; int searched=0; int dfs(int i){ int pre=searched; searched++; checked[i]=true; for(int to:Graph[i]){ if(!checked[to]){ seg.set(to,make_pair(dfs(to),to)); } } int res=1; for(int j=0;j<2;j++){ pair<int,int> tmp=seg.prod(pre,searched); if(tmp.first==-1){ break; } res+=tmp.first; seg.set(tmp.second,e()); } return res; } int main(){ int N; cin>>N; Graph.resize(N); checked.resize(N,false); for(int i=0;i<N;i++){ int x,y; cin>>x>>y; Graph[x-1].push_back(y-1); Graph[y-1].push_back(x-1); } seg=segtree<pair<int,int>,op,e>(N); int ans=dfs(0); cout<<ans<<endl; return 0; }