This is the entire code, i use no header files
this code must input a tree and then write out its high, the problem is in the function High() in the line if (tree[headIndex][1] == -1 && tree[headIndex][2] == -1) {, it says :
Access violation reading location 0xFDFDFE01.
#include<iostream>
using namespace std;
int** InputTree() {
    int n, nd, father;
    int child;
    char dir;
    std::cin >> n;
    int** tree = new int* [n];
    for (int i = 0; i < n; i++) {
        std::cin >> nd;
        tree[i] = new int[3];
        tree[i][0] = nd;
        tree[i][1] = -1;
        tree[i][2] = -1;
    }
    for (int i = 0; i < n - 1; i++) {
        std::cin >> father >> child >> dir;
        if (dir == 'L')
            tree[father][1] = child;
        else
            tree[father][2] = child;
    }
    return tree;
}
int High(int** tree, int headIndex) {
    if (tree[headIndex][1] == -1 && tree[headIndex][2] == -1) {
        return 1;
    }
    int high1 = High(tree, tree[headIndex][1]);
    int high2 = High(tree, tree[headIndex][2]);
    return (high1 > high2 ? high1 : high2);
}
int main(){
    int** t = InputTree();
    cout << High(t, 0);
    system("pause>NULL");
    return 0;
}