結果

問題 No.1582 Vertexes vs Edges
ユーザー shiomusubi496shiomusubi496
提出日時 2021-07-02 22:34:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 200,888 KB
実行使用メモリ 31,764 KB
最終ジャッジ日時 2023-09-11 22:54:43
合計ジャッジ時間 5,376 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
27,992 KB
testcase_01 AC 11 ms
27,920 KB
testcase_02 AC 11 ms
27,928 KB
testcase_03 AC 11 ms
28,072 KB
testcase_04 AC 13 ms
28,112 KB
testcase_05 AC 70 ms
31,496 KB
testcase_06 AC 14 ms
28,092 KB
testcase_07 AC 20 ms
28,508 KB
testcase_08 AC 40 ms
29,740 KB
testcase_09 AC 66 ms
31,228 KB
testcase_10 AC 46 ms
30,020 KB
testcase_11 AC 15 ms
28,228 KB
testcase_12 AC 35 ms
29,324 KB
testcase_13 AC 53 ms
30,112 KB
testcase_14 AC 55 ms
30,120 KB
testcase_15 AC 71 ms
31,012 KB
testcase_16 AC 38 ms
29,356 KB
testcase_17 AC 52 ms
29,964 KB
testcase_18 AC 82 ms
31,552 KB
testcase_19 AC 52 ms
30,288 KB
testcase_20 AC 49 ms
29,880 KB
testcase_21 AC 43 ms
29,680 KB
testcase_22 AC 74 ms
31,164 KB
testcase_23 AC 32 ms
29,124 KB
testcase_24 AC 21 ms
28,488 KB
testcase_25 AC 43 ms
29,716 KB
testcase_26 AC 35 ms
29,328 KB
testcase_27 AC 70 ms
30,856 KB
testcase_28 AC 27 ms
28,868 KB
testcase_29 AC 61 ms
30,380 KB
testcase_30 AC 40 ms
29,460 KB
testcase_31 AC 62 ms
30,660 KB
testcase_32 AC 31 ms
28,996 KB
testcase_33 AC 93 ms
31,708 KB
testcase_34 AC 93 ms
31,764 KB
testcase_35 AC 92 ms
31,700 KB
testcase_36 AC 11 ms
27,920 KB
testcase_37 AC 11 ms
27,932 KB
testcase_38 AC 11 ms
27,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
int N;
vector<int> G[1<<20];
pair<int,int>dfs(int v,int p){
  pair<int,int> res{0,1};
  for(int t:G[v])if(t!=p){
    auto[a,b]=dfs(t,v);
    res.first+=b;
    res.second+=min(a,b);
  }
  return res;
}
signed main(){
  cin>>N;
  for(int i=0;i<N-1;i++){
    int a,b; cin>>a>>b;
    G[--a].push_back(--b);
    G[b].push_back(a);
  }
  auto[a,b]=dfs(0,-1);
  cout<<min(a,b)<<endl;
}
0