結果

問題 No.1582 Vertexes vs Edges
ユーザー fgwiebfaoishfgwiebfaoish
提出日時 2021-07-03 13:16:48
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 2,717 bytes
コンパイル時間 5,286 ms
コンパイル使用メモリ 108,124 KB
実行使用メモリ 42,840 KB
最終ジャッジ日時 2023-09-12 17:19:44
合計ジャッジ時間 12,556 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
20,936 KB
testcase_01 AC 61 ms
20,760 KB
testcase_02 AC 61 ms
22,796 KB
testcase_03 AC 60 ms
20,764 KB
testcase_04 AC 65 ms
21,052 KB
testcase_05 AC 185 ms
40,788 KB
testcase_06 AC 67 ms
21,296 KB
testcase_07 AC 80 ms
28,528 KB
testcase_08 AC 126 ms
33,340 KB
testcase_09 AC 179 ms
37,752 KB
testcase_10 AC 139 ms
35,004 KB
testcase_11 AC 70 ms
25,572 KB
testcase_12 AC 112 ms
29,988 KB
testcase_13 AC 153 ms
35,696 KB
testcase_14 AC 159 ms
35,532 KB
testcase_15 AC 196 ms
39,100 KB
testcase_16 AC 121 ms
28,616 KB
testcase_17 AC 149 ms
35,356 KB
testcase_18 AC 206 ms
41,820 KB
testcase_19 AC 150 ms
33,992 KB
testcase_20 AC 146 ms
34,680 KB
testcase_21 AC 134 ms
33,844 KB
testcase_22 AC 189 ms
37,900 KB
testcase_23 AC 109 ms
29,320 KB
testcase_24 AC 84 ms
29,320 KB
testcase_25 AC 135 ms
33,728 KB
testcase_26 AC 115 ms
29,848 KB
testcase_27 AC 200 ms
36,720 KB
testcase_28 AC 96 ms
28,336 KB
testcase_29 AC 175 ms
34,788 KB
testcase_30 AC 125 ms
34,916 KB
testcase_31 AC 169 ms
35,148 KB
testcase_32 AC 109 ms
31,048 KB
testcase_33 AC 253 ms
40,816 KB
testcase_34 AC 250 ms
42,840 KB
testcase_35 AC 245 ms
42,784 KB
testcase_36 AC 60 ms
20,820 KB
testcase_37 AC 60 ms
20,948 KB
testcase_38 AC 61 ms
22,800 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
using System.Threading;
using System.Runtime.CompilerServices;
static class Program{
	const int mod=(int)1e9+7;
	static List<int>[] li;
	static bool[] b;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int n=s[0],m=n-1;
		li=new List<int>[n+1];
		b=new bool[n+1];
		var dp=new int[n+1][];
		for(int i=1;i<=n;i++){
			li[i]=new List<int>();
			dp[i]=new int[2];
		}
		for(int i=0;i<m;i++){
			var e=sc.Ia;
			li[e[0]].Add(e[1]);
			li[e[1]].Add(e[0]);
		}
		Fu(1,0);
		void Fu(int a,int g){
			b[a]=true;
			dp[a][0]=1;
			for(int i=0;i<li[a].Count;i++){
				var p=li[a][i];
				if(!b[p]){
					Fu(p,g^1);
					dp[a][0]+=dp[p][1];
					dp[a][1]+=Max(dp[p][0],dp[p][1]);
				}
			}
		}
		Console.WriteLine("{0}",n-Max(dp[1][0],dp[1][1]));
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}
0