結果
| 問題 |
No.1582 Vertexes vs Edges
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-02 21:48:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| コード長 | 486 bytes |
| コンパイル時間 | 1,049 ms |
| コンパイル使用メモリ | 72,912 KB |
| 実行使用メモリ | 9,856 KB |
| 最終ジャッジ日時 | 2024-06-29 11:19:46 |
| 合計ジャッジ時間 | 3,355 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
コンパイルメッセージ
main.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
18 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
vector<int>G[1<<17];
pair<int,int>dfs(int u,int p)
{
pair<int,int>ret=make_pair(0,1);
for(int v:G[u])if(v!=p)
{
pair<int,int>q=dfs(v,u);
ret.first+=q.second;
ret.second+=min(q.first,q.second);
}
return ret;
}
main()
{
cin>>N;
for(int i=1;i<N;i++)
{
int a,b;cin>>a>>b;a--,b--;
G[a].push_back(b);
G[b].push_back(a);
}
pair<int,int>p=dfs(0,-1);
cout<<min(p.first,p.second)<<endl;
}