結果

問題 No.1582 Vertexes vs Edges
ユーザー tko919tko919
提出日時 2021-08-23 17:55:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 876 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 195,600 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2024-04-25 09:56:42
合計ジャッジ時間 5,759 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,016 KB
testcase_01 AC 4 ms
5,888 KB
testcase_02 AC 4 ms
6,016 KB
testcase_03 AC 4 ms
5,888 KB
testcase_04 AC 5 ms
6,144 KB
testcase_05 AC 67 ms
9,472 KB
testcase_06 AC 6 ms
6,016 KB
testcase_07 AC 12 ms
6,400 KB
testcase_08 AC 36 ms
7,680 KB
testcase_09 AC 64 ms
9,088 KB
testcase_10 AC 41 ms
7,936 KB
testcase_11 AC 8 ms
6,016 KB
testcase_12 AC 29 ms
7,296 KB
testcase_13 AC 46 ms
8,064 KB
testcase_14 AC 50 ms
8,192 KB
testcase_15 AC 69 ms
9,088 KB
testcase_16 AC 33 ms
7,424 KB
testcase_17 AC 45 ms
8,064 KB
testcase_18 AC 80 ms
9,600 KB
testcase_19 AC 49 ms
8,320 KB
testcase_20 AC 44 ms
7,808 KB
testcase_21 AC 39 ms
7,936 KB
testcase_22 AC 72 ms
9,344 KB
testcase_23 AC 26 ms
7,168 KB
testcase_24 AC 14 ms
6,400 KB
testcase_25 AC 37 ms
7,808 KB
testcase_26 AC 29 ms
7,168 KB
testcase_27 AC 68 ms
8,960 KB
testcase_28 AC 20 ms
6,784 KB
testcase_29 AC 54 ms
8,448 KB
testcase_30 AC 36 ms
7,424 KB
testcase_31 AC 57 ms
8,576 KB
testcase_32 AC 24 ms
7,168 KB
testcase_33 AC 89 ms
9,984 KB
testcase_34 AC 89 ms
9,984 KB
testcase_35 AC 94 ms
9,984 KB
testcase_36 AC 4 ms
5,888 KB
testcase_37 AC 4 ms
5,888 KB
testcase_38 AC 4 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

vector<int> g[101010];
int dp[101010][2];
void dfs(int v,int p){
   for(auto& to:g[v])if(to!=p){
      dfs(to,v);
      dp[v][0]+=dp[to][1];
      dp[v][1]+=min(dp[to][0],dp[to][1]);
   }
   dp[v][1]++;
}

int main(){
   int n;
   cin>>n;
   rep(_,0,n-1){
      int x,y;
      cin>>x>>y;
      x--; y--;
      g[x].push_back(y);
      g[y].push_back(x);
   }

   dfs(0,-1);
   cout<<min(dp[0][0],dp[0][1])<<'\n';
   return 0;
}
0