Submission #4395534


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_Challenge
{
    class _009_B
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            List<int>[] graph = new List<int>[n];
            for (int i = 0; i < n; i++) graph[i] = new List<int>();
            for(int i = 1; i < n; i++)
            {
                int a = ReadInt() - 1;
                graph[a].Add(i);
            }
            WriteLine(GetDepth(graph, 0));
        }

        static int GetDepth(List<int>[] graph,int now)
        {
            if (graph[now].Count == 0) return 0;
            int[] depthes = new int[graph[now].Count];
            for(int i = 0; i < graph[now].Count; i++)
            {
                depthes[i] = GetDepth(graph, graph[now][i]);
            }
            Array.Sort(depthes);
            int depth = 0;
            for(int i = 0; i < depthes.Length; i++)
            {
                if (depth >= depthes[i]) depth++;
                else depth = depthes[i] + 1;
            }
            return depth;
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}

Submission Info

Submission Time
Task B - Tournament
User MiuraMiuMiu
Language C# (Mono 4.6.2.0)
Score 0
Code Size 1925 Byte
Status TLE
Exec Time 2109 ms
Memory 30688 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
AC × 3
AC × 51
TLE × 2
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 96 ms 19744 KB
02.txt AC 96 ms 21792 KB
03.txt AC 87 ms 21796 KB
04.txt AC 89 ms 21796 KB
05.txt AC 92 ms 23844 KB
06.txt AC 88 ms 21796 KB
07.txt AC 92 ms 23844 KB
08.txt AC 95 ms 19624 KB
09.txt AC 94 ms 21796 KB
10.txt AC 90 ms 21796 KB
11.txt AC 204 ms 29076 KB
12.txt TLE 2109 ms 27708 KB
13.txt TLE 2108 ms 25404 KB
14.txt AC 1771 ms 30688 KB
15.txt AC 882 ms 23180 KB
16.txt AC 220 ms 24052 KB
17.txt AC 109 ms 23440 KB
18.txt AC 85 ms 23076 KB
19.txt AC 86 ms 24996 KB
20.txt AC 87 ms 22948 KB
21.txt AC 73 ms 23392 KB
22.txt AC 72 ms 21344 KB
23.txt AC 73 ms 21928 KB
24.txt AC 71 ms 19624 KB
25.txt AC 70 ms 19368 KB
26.txt AC 75 ms 21344 KB
27.txt AC 76 ms 19368 KB
28.txt AC 75 ms 21216 KB
29.txt AC 77 ms 21344 KB
30.txt AC 73 ms 21344 KB
31.txt AC 78 ms 21796 KB
32.txt AC 76 ms 21344 KB
33.txt AC 74 ms 19168 KB
34.txt AC 73 ms 19296 KB
35.txt AC 75 ms 21344 KB
36.txt AC 73 ms 21344 KB
37.txt AC 73 ms 21216 KB
38.txt AC 71 ms 19296 KB
39.txt AC 70 ms 21344 KB
40.txt AC 70 ms 19296 KB
41.txt AC 21 ms 9172 KB
42.txt AC 22 ms 11220 KB
43.txt AC 21 ms 9172 KB
44.txt AC 22 ms 11220 KB
45.txt AC 22 ms 11220 KB
46.txt AC 22 ms 11220 KB
47.txt AC 21 ms 9172 KB
48.txt AC 21 ms 11220 KB
49.txt AC 22 ms 11220 KB
50.txt AC 21 ms 9172 KB
s1.txt AC 21 ms 11220 KB
s2.txt AC 22 ms 11220 KB
s3.txt AC 21 ms 9172 KB