邓心一 6 years ago
parent
commit
93ff910c3a
1 changed files with 35 additions and 0 deletions
  1. 35 0
      written-exam/2019-meituan/no2/Main.java

+ 35 - 0
written-exam/2019-meituan/no2/Main.java

@@ -0,0 +1,35 @@
+import java.util.*;
+
+public class Main {
+  private static final int MOD = 1000000007;
+
+  private static class Node {
+    int color;
+    ArrayList<Node> children;
+
+    Node() {
+      this.children = new ArrayList<>();
+    }
+  }
+
+  public static void main(String[] args) {
+    Scanner scanner = new Scanner(System.in);
+    int n = scanner.nextInt();
+    Node[] nodes = new Node[n];
+    nodes[0] = new Node();
+    for (int i = 1, father; i < n; i++) {
+      father = scanner.nextInt();
+      nodes[i] = new Node();
+      nodes[father].children.add(nodes[i]);
+    }
+    for (int i = 0; i < n; i++)
+      nodes[i].color = scanner.nextInt();
+    scanner.close();
+    System.out.println(cutTree(nodes[0]));
+  }
+
+  private static int cutTree(Node root) {
+    
+    return 0;
+  }
+}