結果

問題 No.806 木を道に
ユーザー keymoon
提出日時 2019-02-24 16:42:27
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,137 bytes
コンパイル時間 3,608 ms
コンパイル使用メモリ 113,436 KB
実行使用メモリ 36,380 KB
最終ジャッジ日時 2024-07-07 03:40:34
合計ジャッジ時間 4,844 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 2
other RE * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
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) => Enumerable.Repeat(0, int.Parse(Console.ReadLine()) - 1).SelectMany(_ => Console.ReadLine().Split().Select(int.Parse)).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