Frames

Untitled

0
1import java.util.*;
2import java.io.*;
3
4public class is_bst_hard {
5 class FastScanner {
6 StringTokenizer tok = new StringTokenizer("");
7 BufferedReader in;
8
9 FastScanner() {
10 in = new BufferedReader(new InputStreamReader(System.in));
11 }
12
13 String next() throws IOException {
14 while (!tok.hasMoreElements())
15 tok = new StringTokenizer(in.readLine());
16 return tok.nextToken();
17 }
18 int nextInt() throws IOException {
19 return Integer.parseInt(next());
20 }
21 }
22
23 public class IsBST {
24 class Node {
25 int key;
26 int left;
27 int right;
28
29 Node(int key, int left, int right) {
30 this.left = left;
31 this.right = right;
32 this.key = key;
33 }
34 }
35
36 int nodes;
37 Node[] tree;
38
39 void read() throws IOException {
40 FastScanner in = new FastScanner();
41 nodes = in.nextInt();
42 tree = new Node[nodes];
43 for (int i = 0; i < nodes; i++) {
44 tree[i] = new Node(in.nextInt(), in.nextInt(), in.nextInt());
45 }
46 }
47
48 boolean isBinarySearchTree() {
49 // Implement correct algorithm here
50 return true;
51 }
52 }
53
54 static public void main(String[] args) throws IOException {
55 new Thread(null, new Runnable() {
56 public void run() {
57 try {
58 new is_bst_hard().run();
59 } catch (IOException e) {
60 }
61 }
62 }, "1", 1 << 26).start();
63 }
64 public void run() throws IOException {
65 IsBST tree = new IsBST();
66 tree.read();
67 if (tree.solve()) {
68 System.out.println("CORRECT");
69 } else {
70 System.out.println("INCORRECT");
71 }
72 }
73}
74