結果

問題 No.1582 Vertexes vs Edges
ユーザー kotatsugamekotatsugame
提出日時 2021-07-02 21:48:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 973 ms
コンパイル使用メモリ 72,724 KB
実行使用メモリ 9,952 KB
最終ジャッジ日時 2023-09-11 21:39:19
合計ジャッジ時間 3,846 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,480 KB
testcase_01 AC 4 ms
6,516 KB
testcase_02 AC 4 ms
6,548 KB
testcase_03 AC 4 ms
6,440 KB
testcase_04 AC 5 ms
6,584 KB
testcase_05 AC 61 ms
9,352 KB
testcase_06 AC 6 ms
6,540 KB
testcase_07 AC 12 ms
6,976 KB
testcase_08 AC 32 ms
7,820 KB
testcase_09 AC 57 ms
9,052 KB
testcase_10 AC 37 ms
8,080 KB
testcase_11 AC 8 ms
6,744 KB
testcase_12 AC 26 ms
7,584 KB
testcase_13 AC 42 ms
8,232 KB
testcase_14 AC 43 ms
8,252 KB
testcase_15 AC 59 ms
9,036 KB
testcase_16 AC 31 ms
7,628 KB
testcase_17 AC 41 ms
8,160 KB
testcase_18 AC 72 ms
9,428 KB
testcase_19 AC 43 ms
8,292 KB
testcase_20 AC 38 ms
8,112 KB
testcase_21 AC 35 ms
7,920 KB
testcase_22 AC 62 ms
9,164 KB
testcase_23 AC 23 ms
7,520 KB
testcase_24 AC 13 ms
7,048 KB
testcase_25 AC 34 ms
8,128 KB
testcase_26 AC 26 ms
7,484 KB
testcase_27 AC 58 ms
8,888 KB
testcase_28 AC 20 ms
7,204 KB
testcase_29 AC 49 ms
8,488 KB
testcase_30 AC 32 ms
7,808 KB
testcase_31 AC 50 ms
8,832 KB
testcase_32 AC 22 ms
7,352 KB
testcase_33 AC 78 ms
9,952 KB
testcase_34 AC 80 ms
9,712 KB
testcase_35 AC 78 ms
9,668 KB
testcase_36 AC 4 ms
6,608 KB
testcase_37 AC 4 ms
6,420 KB
testcase_38 AC 4 ms
6,452 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:18:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   18 | main()
      | ^~~~

ソースコード

diff #

#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;
}
0