Language: C++

#include<iostream>
#include<vector>
#include <iterator>
#include<algorithm>
static const int NIL = -1;
static const int NumberChild = 2;
class Tree {
private:
    int id;
    int parent;
    int child[NumberChild];
 
public:
    Tree() {
        id = child[0] = child[1] = parent = NIL;
    }
    void AddParent(int ID) {
        parent = ID;
        return;
    }
    void AddID(int ID) {
        id = ID;
        return;
    }
    void AddChild(std::vector<int>&Child) {
        for (unsigned int i = 0; i < Child.size(); ++i) {
            child[i] = Child[i];
 
        }
 
        return;
    }
    int GetRoot(std::vector<Tree> nodes, int ID) {
        int RootID = ID;
        if (RootID != NIL&&nodes[RootID].parent != NIL) {
            RootID = GetRoot(nodes, nodes[RootID].parent);
        }
        return RootID;
    }
    void PreorderTreeWalk(std::vector<Tree> nodes, int ID) {
        if (ID != NIL) {
            std::cout << " " << nodes[ID].id;
            PreorderTreeWalk(nodes, nodes[ID].child[0]);
            PreorderTreeWalk(nodes, nodes[ID].child[1]);
        }
 
        return;
    }
    void InorderTreeWalk(std::vector<Tree> nodes, int ID) {
        if (ID != NIL) {
            InorderTreeWalk(nodes, nodes[ID].child[0]);
            std::cout << " " << nodes[ID].id;
            InorderTreeWalk(nodes, nodes[ID].child[1]);
        }
 
        return;
    }
    void PostorderTreeWalk(std::vector<Tree> nodes, int ID) {
        if (ID != NIL) {
 
            PostorderTreeWalk(nodes, nodes[ID].child[0]);
            PostorderTreeWalk(nodes, nodes[ID].child[1]);
            if (nodes[ID].id != NIL)std::cout << " " << nodes[ID].id;
        }
 
        return;
    }
    void GetVctorPostorderTreeWalk(std::vector<Tree> nodes, std::vector<int>& returnvector, int ID) {
 
        if (ID != NIL) {
 
            GetVctorPostorderTreeWalk(nodes, returnvector, nodes[ID].child[0]);
            GetVctorPostorderTreeWalk(nodes, returnvector, nodes[ID].child[1]);
            if (nodes[ID].id != NIL)returnvector.push_back(nodes[ID].id);
        }
 
        return;
    }
    void Reconstruct(std::vector<int>Pre, std::vector<int>In, std::vector<Tree> &nodes, const int Root, int &cnt) {
 
        unsigned int m = std::distance(In.begin(), std::find(In.begin(), In.end(), Root));
 
        //nodes[cnt].AddID(Root);
        if (Root == NIL) { return; }
        nodes[Root].AddID(Root);
 
        if (m == 0) {
            std::vector<int>RestPre;
            RestPre.push_back(NIL);
            if (m < Pre.size() - 1) {
                RestPre.pop_back();
                std::copy(&Pre[m] + 1, &Pre[Pre.size() - 1] + 1, std::back_inserter(RestPre));
            }
            std::vector<int> RestIn;
            RestIn.push_back(NIL);
            if (m < In.size() - 1) {
                RestIn.pop_back();
                std::copy(&In[m] + 1, &In[In.size() - 1] + 1, std::back_inserter(RestIn));
            }
            std::vector<int> child(2);
            child[0] = NIL;
            child[1] = RestPre.empty() ? NIL : RestPre[0];
            nodes[Root].AddChild(child);
            for (unsigned int i = 0; i < child.size(); ++i) {
 
                if (child[i] != NIL) { nodes[child[i]].AddParent(Root); }
            }
            Reconstruct(RestPre, RestIn, nodes, RestPre[0], ++cnt);
            return;
        }
        std::vector<int>PreLeft;
        std::copy(&Pre[1], &Pre[m] + 1, std::back_inserter(PreLeft));
        std::vector<int>InLeft;
        std::vector<int>PreRight;
        PreRight.push_back(NIL);
        //PreRight={NIL};
        std::vector<int> InRight;
        InRight.push_back(NIL);
        //InRight={NIL};
        std::copy(&In[0], &In[m - 1] + 1, std::back_inserter(InLeft));
 
        if (m < Pre.size() - 1) {
            PreRight.pop_back();
            std::copy(&Pre[m] + 1, &Pre[Pre.size() - 1] + 1, std::back_inserter(PreRight));
        }
        if (m < In.size() - 1) {
            InRight.pop_back();
            std::copy(&In[m] + 1, &In[In.size() - 1] + 1, std::back_inserter(InRight));
        }
 
 
 
 
        std::vector<int> child(2);
        child[0] = PreLeft.empty() ? NIL : PreLeft[0];
        child[1] = PreRight.empty() ? NIL : PreRight[0];
        //nodes[cnt].AddChild(child);
        nodes[Root].AddChild(child);
        for (unsigned int i = 0; i < child.size(); ++i) {
 
            if (child[i] != NIL) { nodes[child[i]].AddParent(Root); }
        }
        Reconstruct(PreLeft, InLeft, nodes, PreLeft[0], ++cnt);
        Reconstruct(PreRight, InRight, nodes, PreRight[0], ++cnt);
    }
};
 
void SetVector(std::vector<int>&InputVector) {
    for (unsigned int i = 0; i < InputVector.size(); ++i) {
        std::cin >> InputVector[i];
    }
    return;
}
int main(void) {
 
    int n;
    std::cin >> n;
    std::vector<int>Pre(n);
    std::vector<int>In(n);
    SetVector(Pre);
    SetVector(In);
    std::vector<Tree> nodes(n + 1);
    //ReconstructWithNoParent
    int cnt = 0;
    nodes[1].Reconstruct(Pre, In, nodes, Pre[0], cnt);
 
    //nodes[1].PostorderTreeWalk(nodes, 1);
    std::vector<int>Print;
    nodes[1].GetVctorPostorderTreeWalk(nodes, Print, nodes[1].GetRoot(nodes, 1));
    //Print=nodes[1].GetVctorPostorderTreeWalk(nodes, 1);
    for (unsigned int i = 0; i < Print.size(); ++i) {
        if (i) { std::cout << " "; }
        std::cout << Print[i];
        if (i == Print.size() - 1) { std::cout << std::endl; }
    }
    return 0;
}


Compiler output:
a.cc:9:1: error: extended character   is not valid in an identifier
    9 |     int id;
      | ^
a.cc:9:1: error: extended character   is not valid in an identifier
a.cc:9:1: error: extended character   is not valid in an identifier
a.cc:9:1: error: extended character   is not valid in an identifier
a.cc:10:1: error: extended character   is not valid in an identifier
   10 |     int parent;
      | ^
a.cc:10:1: error: extended character   is not valid in an identifier
a.cc:10:1: error: extended character   is not valid in an identifier
a.cc:10:1: error: extended character   is not valid in an identifier
a.cc:11:1: error: extended character   is not valid in an identifier
   11 |     int child[NumberChild];
      | ^
a.cc:11:1: error: extended character   is not valid in an identifier
a.cc:11:1: error: extended character   is not valid in an identifier
a.cc:11:1: error: extended character   is not valid in an identifier
a.cc:12:1: error: extended character   is not valid in an identifier
   12 |  
      | ^
a.cc:14:1: error: extended character   is not valid in an identifier
   14 |     Tree() {
      | ^
a.cc:14:1: error: extended character   is not valid in an identifier
a.cc:14:1: error: extended character   is not valid in an identifier
a.cc:14:1: error: extended character   is not valid in an identifier
a.cc:15:1: error: extended character   is not valid in an identifier
   15 |         id = child[0] = child[1] = parent = NIL;
      | ^
a.cc:15:1: error: extended character   is not valid in an identifier
a.cc:15:1: error: extended character   is not valid in an identifier
a.cc:15:1: error: extended character   is not valid in an identifier
a.cc:15:1: error: extended character   is not valid in an identifier
a.cc:15:1: error: extended character   is not valid in an identifier
a.cc:15:1: error: extended character   is not valid in an identifier
a.cc:15:1: error: extended character   is not valid in an identifier
a.cc:16:1: error: extended character   is not valid in an identifier
   16 |     }
      | ^
a.cc:16:1: error: extended character   is not valid in an identifier
a.cc:16:1: error: extended character   is not valid in an identifier
a.cc:16:1: error: extended character   is not valid in an identifier
a.cc:17:1: error: extended character   is not valid in an identifier
   17 |     void AddParent(int ID) {
      | ^
a.cc:17:1: error: extended character   is not valid in an identifier
a.cc:17:1: error: extended character   is not valid in an identifier
a.cc:17:1: error: extended character   is not valid in an identifier
a.cc:18:1: error: extended character   is not valid in an identifier
   18 |         parent = ID;
      | ^
a.cc:18:1: error: extended character   is not valid in an identifier
a.cc:18:1: error: extended character   is not valid in an identifier
a.cc:18:1: error: extended character   is not valid in an identifier
a.cc:18:1: error: extended character   is not valid in an identifier
a.cc:18:1: error: extended character   is not valid in an identifier
a.cc:18:1: error: extended character   is not valid in an identifier
a.cc:18:1: error: extended character   is not valid in an identifier
a.cc:19:1: error: extended character   is not valid in an identifier
   19 |         return;
      | ^
a.cc:19:1: error: extended character   is not valid in an identifier
a.cc:19:1: error: extended character   is not valid in an identifier
a.cc:19:1: error: extended character   is not valid in an identifier
a.cc:19:1: error: extended character   is not valid in an identifier
a.cc:19:1: error: extended character   is not valid in an identifier
a.cc:19:1: error: extended character   is not valid in an identifier
a.cc:19:1: error: extended character   is not valid in an identifier
a.cc:20:1: error: extended character   is not valid in an identifier
   20 |     }
      | ^
a.cc:20:1: error: extended character   is not valid in an identifier
a.cc:20:1: error: extended character   is not valid in an identifier
a.cc:20:1: error: extended character   is not valid in an identifier
a.cc:21:1: error: extended character   is not valid in an identifier
   21 |     void AddID(int ID) {
      | ^
a.cc:21:1: error: extended character   is not valid in an identifier
a.cc:21:1: error: extended character   is not valid in an identifier
a.cc:21:1: error: extended character   is not valid in an identifier
a.cc:22:1: error: extended character   is not valid in an identifier
   22 |         id = ID;
      | ^
a.cc:22:1: error: extended character   is not valid in an identifier
a.cc:22:1: error: extended character   is not valid in an identifier
a.cc:22:1: error: extended character   is not valid in an identifier
a.cc:22:1: error: extended character   is not valid in an identifier
a.cc:22:1: error: extended character   is not valid in an identifier
a.cc:22:1: error: extended character   is not valid in an identifier
a.cc:22:1: error: extended character   is not valid in an identifier
a.cc:23:1: error: extended character   is not valid in an identifier
   23 |         return;
      | ^
a.cc:23:1: error: extended character   is not valid in an identifier
a.cc:23:1: error: extended character   is not valid in an identifier
a.cc:23:1: error: extended character   is not valid in an identifier
a.cc:23:1: error: extended character   is not valid in an identifier
a.cc:23:1: error: extended character   is not valid in an identifier
a.cc:23:1: error: extended character   is not valid in an identifier
a.cc:23:1: error: extended character   is not valid in an identifier
a.cc:24:1: error: extended character   is not valid in an identifier
   24 |     }
      | ^
a.cc:24:1: error: extended character   is not valid in an identifier
a.cc:24:1: error: extended character   is not valid in an identifier
a.cc:24:1: error: extended character   is not valid in an identifier
a.cc:25:1: error: extended character   is not valid in an identifier
   25 |     void AddChild(std::vector<int>&Child) {
      | ^
a.cc:25:1: error: extended character   is not valid in an identifier
a.cc:25:1: error: extended character   is not valid in an identifier
a.cc:25:1: error: extended character   is not valid in an identifier
a.cc:26:1: error: extended character   is not valid in an identifier
   26 |         for (unsigned int i = 0; i < Child.size(); ++i) {
      | ^
a.cc:26:1: error: extended character   is not valid in an identifier
a.cc:26:1: error: extended character   is not valid in an identifier
a.cc:26:1: error: extended character   is not valid in an identifier
a.cc:26:1: error: extended character   is not valid in an identifier
a.cc:26:1: error: extended character   is not valid in an identifier
a.cc:26:1: error: extended character   is not valid in an identifier
a.cc:26:1: error: extended character   is not valid in an identifier
a.cc:27:1: error: extended character   is not valid in an identifier
   27 |             child[i] = Child[i];
      | ^
a.cc:27:1: error: extended character   is not valid in an identifier
a.cc:27:1: error: extended character   is not valid in an identifier
a.cc:27:1: error: extended character   is not valid in an identifier
a.cc:27:1: error: extended character   is not valid in an identifier
a.cc:27:1: error: extended character   is not valid in an identifier
a.cc:27:1: error: extended character   is not valid in an identifier
a.cc:27:1: error: extended character   is not valid in an identifier
a.cc:27:1: error: extended character   is not valid in an identifier
a.cc:27:1: error: extended character   is not valid in an identifier
a.cc:27:1: error: extended character   is not valid in an identifier
a.cc:27:1: error: extended character   is not valid in an identifier
a.cc:28:1: error: extended character   is not valid in an identifier
   28 |  
      | ^
a.cc:29:1: error: extended character   is not valid in an identifier
   29 |         }
      | ^
a.cc:29:1: error: extended character   is not valid in an identifier
a.cc:29:1: error: extended character   is not valid in an identifier
a.cc:29:1: error: extended character   is not valid in an identifier
a.cc:29:1: error: extended character   is not valid in an identifier
a.cc:29:1: error: extended character   is not valid in an identifier
a.cc:29:1: error: extended character   is not valid in an identifier
a.cc:29:1: error: extended character   is not valid in an identifier
a.cc:30:1: error: extended character   is not valid in an identifier
   30 |  
      | ^
a.cc:31:1: error: extended character   is not valid in an identifier
   31 |         return;
      | ^
a.cc:31:1: error: extended character   is not valid in an identifier
a.cc:31:1: error: extended character   is not valid in an identifier
a.cc:31:1: error: extended character   is not valid in an identifier
a.cc:31:1: error: extended character   is not valid in an identifier
a.cc:31:1: error: extended character   is not valid in an identifier
a.cc:31:1: error: extended character   is not valid in an identifier
a.cc:31:1: error: extended character   is not valid in an identifier
a.cc:32:1: error: extended character   is not valid in an identifier
   32 |     }
      | ^
a.cc:32:1: error: extended character   is not valid in an identifier
a.cc:32:1: error: extended character   is not valid in an identifier
a.cc:32:1: error: extended character   is not valid in an identifier
a.cc:33:1: error: extended character   is not valid in an identifier
   33 |     int GetRoot(std::vector<Tree> nodes, int ID) {
      | ^
a.cc:33:1: error: extended character   is not valid in an identifier
a.cc:33:1: error: extended character   is not valid in an identifier
a.cc:33:1: error: extended character   is not valid in an identifier
a.cc:34:1: error: extended character   is not valid in an identifier
   34 |         int RootID = ID;
      | ^
a.cc:34:1: error: extended character   is not valid in an identifier
a.cc:34:1: error: extended character   is not valid in an identifier
a.cc:34:1: error: extended character   is not vali