Submission #4395895
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); } int[] depthes = new int[n]; for (int i = 0; i < n; i++) depthes[i] = -1; WriteLine(GetDepth(graph, ref depthes, 0)); } static int GetDepth(List<int>[] graph,ref int[] depthes, int now) { if (depthes[now] >= 0) return depthes[now]; int len = graph[now].Count; if (len == 0) return 0; int[] nowDepthes = new int[len]; for (int i = 0; i < len; i++) { nowDepthes[i] = GetDepth(graph, ref depthes, graph[now][i]); } Array.Sort(depthes); int depth = 0; for (int i = 0; i < len; i++) { if (depth >= nowDepthes[i]) depth++; else depth = nowDepthes[i] + 1; } depthes[now] = depth; 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 | 2169 Byte |
Status | WA |
Exec Time | 2110 ms |
Memory | 35092 KB |
Judge Result
Set Name | Sample | All | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 800 | ||||||||||
Status |
|
|
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 | TLE | 2109 ms | 22180 KB |
02.txt | TLE | 2109 ms | 22180 KB |
03.txt | TLE | 2109 ms | 24228 KB |
04.txt | TLE | 2109 ms | 22052 KB |
05.txt | TLE | 2109 ms | 22180 KB |
06.txt | TLE | 2109 ms | 22052 KB |
07.txt | TLE | 2109 ms | 22052 KB |
08.txt | TLE | 2109 ms | 24228 KB |
09.txt | TLE | 2109 ms | 22180 KB |
10.txt | TLE | 2109 ms | 20132 KB |
11.txt | TLE | 2110 ms | 35092 KB |
12.txt | TLE | 2109 ms | 22820 KB |
13.txt | TLE | 2109 ms | 20388 KB |
14.txt | TLE | 2109 ms | 20260 KB |
15.txt | TLE | 2109 ms | 22308 KB |
16.txt | TLE | 2109 ms | 20260 KB |
17.txt | TLE | 2109 ms | 24356 KB |
18.txt | TLE | 2109 ms | 22308 KB |
19.txt | TLE | 2109 ms | 24356 KB |
20.txt | TLE | 2109 ms | 20260 KB |
21.txt | AC | 75 ms | 19752 KB |
22.txt | WA | 84 ms | 19752 KB |
23.txt | WA | 96 ms | 22312 KB |
24.txt | WA | 113 ms | 20008 KB |
25.txt | WA | 142 ms | 21800 KB |
26.txt | WA | 214 ms | 21672 KB |
27.txt | WA | 358 ms | 19752 KB |
28.txt | WA | 1022 ms | 21216 KB |
29.txt | TLE | 2109 ms | 23392 KB |
30.txt | TLE | 2109 ms | 21344 KB |
31.txt | TLE | 2109 ms | 20132 KB |
32.txt | TLE | 2109 ms | 23716 KB |
33.txt | TLE | 2109 ms | 21540 KB |
34.txt | TLE | 2109 ms | 19296 KB |
35.txt | TLE | 2109 ms | 19296 KB |
36.txt | TLE | 2109 ms | 19296 KB |
37.txt | TLE | 2109 ms | 19296 KB |
38.txt | TLE | 2109 ms | 23392 KB |
39.txt | TLE | 2109 ms | 19296 KB |
40.txt | WA | 1017 ms | 21344 KB |
41.txt | AC | 22 ms | 9172 KB |
42.txt | AC | 23 ms | 11220 KB |
43.txt | AC | 22 ms | 9172 KB |
44.txt | AC | 23 ms | 11220 KB |
45.txt | WA | 22 ms | 11220 KB |
46.txt | AC | 23 ms | 9172 KB |
47.txt | AC | 23 ms | 11220 KB |
48.txt | AC | 22 ms | 9172 KB |
49.txt | AC | 22 ms | 11220 KB |
50.txt | AC | 22 ms | 9172 KB |
s1.txt | WA | 22 ms | 9172 KB |
s2.txt | WA | 22 ms | 9172 KB |
s3.txt | AC | 22 ms | 9172 KB |