fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. struct Node {
  6. Node(int v) : val(v) {}
  7. int val;
  8. vector<Node*> children;
  9. };
  10.  
  11. Node *readTreeNode() {
  12. int val, children;
  13. cin >> val >> children;
  14. Node *node = new Node(val);
  15. for (int i = 0; i<children; ++i)
  16. node->children.push_back(readTreeNode());
  17. return node;
  18. }
  19.  
  20. int main() {
  21. Node *root = readTreeNode();
  22. // Do the cleanup..
  23. return 0;
  24. }
Success #stdin #stdout 0s 3460KB
stdin
1 3
2 1
3 0
4 0
5 0
stdout
Standard output is empty