Submission #4395695
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; var dict = new SortedDictionary<int, bool>(); for(int i = 0; i < graph[now].Count; i++) { dict.Add(GetDepth(graph, graph[now][i]), true); } int depth = 0; foreach(int key in dict.Keys) { if (depth >= key) depth++; else depth = key + 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 | 1873 Byte |
Status | RE |
Exec Time | 2109 ms |
Memory | 35544 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 | RE | 87 ms | 20384 KB |
02.txt | RE | 95 ms | 24480 KB |
03.txt | RE | 98 ms | 24484 KB |
04.txt | RE | 105 ms | 22436 KB |
05.txt | RE | 107 ms | 22436 KB |
06.txt | RE | 117 ms | 22436 KB |
07.txt | RE | 93 ms | 24480 KB |
08.txt | RE | 88 ms | 26532 KB |
09.txt | RE | 91 ms | 26532 KB |
10.txt | RE | 93 ms | 20388 KB |
11.txt | TLE | 2109 ms | 35544 KB |
12.txt | TLE | 2109 ms | 26508 KB |
13.txt | RE | 124 ms | 24996 KB |
14.txt | RE | 82 ms | 24740 KB |
15.txt | RE | 85 ms | 20644 KB |
16.txt | RE | 107 ms | 24864 KB |
17.txt | RE | 95 ms | 22820 KB |
18.txt | RE | 88 ms | 26660 KB |
19.txt | RE | 86 ms | 20516 KB |
20.txt | RE | 87 ms | 20516 KB |
21.txt | RE | 67 ms | 21668 KB |
22.txt | RE | 65 ms | 21672 KB |
23.txt | RE | 66 ms | 20264 KB |
24.txt | RE | 67 ms | 26152 KB |
25.txt | RE | 71 ms | 25896 KB |
26.txt | RE | 69 ms | 21672 KB |
27.txt | RE | 69 ms | 23720 KB |
28.txt | RE | 71 ms | 20904 KB |
29.txt | RE | 71 ms | 23332 KB |
30.txt | RE | 110 ms | 19492 KB |
31.txt | RE | 85 ms | 20388 KB |
32.txt | RE | 78 ms | 21924 KB |
33.txt | RE | 75 ms | 19748 KB |
34.txt | RE | 97 ms | 21412 KB |
35.txt | RE | 75 ms | 19364 KB |
36.txt | RE | 96 ms | 23204 KB |
37.txt | RE | 75 ms | 21344 KB |
38.txt | RE | 76 ms | 21284 KB |
39.txt | RE | 76 ms | 25440 KB |
40.txt | RE | 74 ms | 20648 KB |
41.txt | RE | 26 ms | 9184 KB |
42.txt | AC | 29 ms | 11604 KB |
43.txt | RE | 28 ms | 11104 KB |
44.txt | AC | 28 ms | 11476 KB |
45.txt | RE | 26 ms | 11232 KB |
46.txt | RE | 32 ms | 11232 KB |
47.txt | AC | 29 ms | 9428 KB |
48.txt | AC | 31 ms | 11604 KB |
49.txt | RE | 31 ms | 13280 KB |
50.txt | RE | 37 ms | 11232 KB |
s1.txt | AC | 30 ms | 11476 KB |
s2.txt | AC | 31 ms | 13652 KB |
s3.txt | RE | 27 ms | 9184 KB |