結果

問題 No.812 Change of Class
ユーザー keymoonkeymoon
提出日時 2019-04-12 22:03:41
言語 C#(csc)
(csc 3.9.0)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,114 bytes
コンパイル時間 2,677 ms
コンパイル使用メモリ 106,184 KB
実行使用メモリ 822,488 KB
最終ジャッジ日時 2023-09-03 12:17:57
合計ジャッジ時間 11,686 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 328 ms
35,716 KB
testcase_01 AC 108 ms
27,052 KB
testcase_02 AC 209 ms
30,268 KB
testcase_03 AC 377 ms
35,196 KB
testcase_04 AC 343 ms
36,184 KB
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

//#define topt
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


class P
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        List<int>[] neighbours = Enumerable.Repeat(0, nm[0]).Select(_ => new List<int>()).ToArray();
        for (int i = 0; i < nm[1]; i++)
        {
            int[] ab = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            neighbours[ab[0]].Add(ab[1]);
            neighbours[ab[1]].Add(ab[0]);
        }
        int q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            int query = int.Parse(Console.ReadLine()) - 1;

            var maxDepth = 0;
            var count = 0;

            Stack<Tuple<int, int, int>> stack = new Stack<Tuple<int, int, int>>();
            foreach (var neighbour in neighbours[query]) stack.Push(new Tuple<int, int, int>(neighbour, 0, query));
            while (stack.Count > 0)
            {
                var elem = stack.Pop();
                var index = elem.Item1;
                var depth = elem.Item2;
                var came = elem.Item3;
                count++;
                maxDepth = Max(maxDepth, depth);
                foreach (var neighbour in neighbours[index])
                {
                    if (neighbour == came) continue;
                    stack.Push(new Tuple<int, int, int>(neighbour, depth + 1, index));
                }
            }
            //1→2→4→8→16
            int depthLog = 0;
            while ((1 << depthLog) <= maxDepth) depthLog++;

            Console.WriteLine($"{count} {depthLog}");
        }
    }
}
0