結果

問題 No.806 木を道に
ユーザー keymoonkeymoon
提出日時 2019-02-24 16:43:48
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 1,040 bytes
コンパイル時間 2,180 ms
コンパイル使用メモリ 110,924 KB
実行使用メモリ 43,916 KB
最終ジャッジ日時 2023-09-21 09:29:36
合計ジャッジ時間 7,668 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
21,860 KB
testcase_01 AC 69 ms
21,836 KB
testcase_02 AC 69 ms
21,764 KB
testcase_03 AC 68 ms
21,804 KB
testcase_04 AC 68 ms
21,856 KB
testcase_05 AC 70 ms
23,916 KB
testcase_06 AC 69 ms
21,928 KB
testcase_07 AC 69 ms
21,804 KB
testcase_08 AC 69 ms
23,868 KB
testcase_09 AC 68 ms
21,824 KB
testcase_10 AC 112 ms
31,444 KB
testcase_11 AC 102 ms
27,388 KB
testcase_12 AC 236 ms
39,436 KB
testcase_13 AC 186 ms
37,400 KB
testcase_14 AC 233 ms
39,964 KB
testcase_15 AC 236 ms
39,296 KB
testcase_16 AC 130 ms
32,492 KB
testcase_17 AC 221 ms
40,624 KB
testcase_18 AC 86 ms
28,704 KB
testcase_19 AC 114 ms
31,600 KB
testcase_20 AC 224 ms
38,556 KB
testcase_21 AC 144 ms
33,604 KB
testcase_22 AC 276 ms
43,916 KB
testcase_23 AC 266 ms
43,844 KB
testcase_24 AC 157 ms
35,740 KB
testcase_25 AC 203 ms
40,732 KB
testcase_26 AC 113 ms
28,008 KB
testcase_27 AC 220 ms
40,704 KB
testcase_28 AC 75 ms
21,856 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.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;


class Ph
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[][] a = Enumerable.Repeat(0, n - 1).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        Assert(3 <= n && n <= 1e5);
        Assert(a.Length == n - 1);
        Assert(a.All(x => x.All(y => 1 <= y && y <= n)));
        var answer = Solve(n, a);
        Console.WriteLine(answer);
    }

    static int Solve(int n, int[][] a) => a.SelectMany(x => x).GroupBy(x => x).Sum(x => Max(0, x.Count() - 2));

    //直径から伸びている部分木の本数
    static int Lie1(int n, int[][] a)
    {
        return 0;
    }

    static void Assert(bool condition)
    {
        if (!condition) throw new Exception();
    }
}
0