Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <stack>
#include <map>
using namespace std;
int N;

int main() {
    while(cin >> N, N){
        pair<int, int> p;
        vector<p> vp;
        vp.push_back({0, 0});
        for(int i=1; i<N; ++i){
            int n, d; cin >> n >> d;
            int x, y;
            if(d==0){
                x = vp[n].first-1;
                y = vp[n].second;
            }else if(d==1){
               x = vp[n].first;
                y = vp[n].second-1;
            }else if(d==2){
                x = vp[n].first+1;
                y = vp[n].second;
            }else if(d==3){
                x = vp[n].first;
                y = vp[n].second+1;
            } 
            vp.push_back({x, y});            
        }
        int ansxu=0, ansxd=0, ansyl=0, ansyr=0;
        for(int i=0; i<vp.size(); ++i){
            ansxu = max(ansxu, vp[i].first);
            if(vp[i].first<0){
                ansxd = min(ansxd, vp[i].first);
            }
            ansyr = max(ansyr, vp[i].second);
            if(vp[i].second<0){
                ansyl = min(ansxd, vp[i].second);
            }
            //cout << vp[i].first << " " << vp[i].second << endl;
        }
        cout << ansxu-ansxd+1 << " " << -ansyl+ansyr+1 << endl;
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   15 |         vector<p> vp;
      |                 ^
a.cc:15:17: note:   expected a type, got 'p'
a.cc:15:17: error: template argument 2 is invalid
a.cc:16:12: error: request for member 'push_back' in 'vp', which is of non-class type 'int'
   16 |         vp.push_back({0, 0});
      |            ^~~~~~~~~
a.cc:21:23: error: invalid types 'int[int]' for array subscript
   21 |                 x = vp[n].first-1;
      |                       ^
a.cc:22:23: error: invalid types 'int[int]' for array subscript
   22 |                 y = vp[n].second;
      |                       ^
a.cc:24:22: error: invalid types 'int[int]' for array subscript
   24 |                x = vp[n].first;
      |                      ^
a.cc:25:23: error: invalid types 'int[int]' for array subscript
   25 |                 y = vp[n].second-1;
      |                       ^
a.cc:27:23: error: invalid types 'int[int]' for array subscript
   27 |                 x = vp[n].first+1;
      |                       ^
a.cc:28:23: error: invalid types 'int[int]' for array subscript
   28 |                 y = vp[n].second;
      |                       ^
a.cc:30:23: error: invalid types 'int[int]' for array subscript
   30 |                 x = vp[n].first;
      |                       ^
a.cc:31:23: error: invalid types 'int[int]' for array subscript
   31 |                 y = vp[n].second+1;
      |                       ^
a.cc:33:16: error: request for member 'push_back' in 'vp', which is of non-class type 'int'
   33 |             vp.push_back({x, y});
      |                ^~~~~~~~~
a.cc:36:27: error: request for member 'size' in 'vp', which is of non-class type 'int'
   36 |         for(int i=0; i<vp.size(); ++i){
      |                           ^~~~
a.cc:37:34: error: invalid types 'int[int]' for array subscript
   37 |             ansxu = max(ansxu, vp[i].first);
      |                                  ^
a.cc:38:18: error: invalid types 'int[int]' for array subscript
   38 |             if(vp[i].first<0){
      |                  ^
a.cc:39:38: error: invalid types 'int[int]' for array subscript
   39 |                 ansxd = min(ansxd, vp[i].first);
      |                                      ^
a.cc:41:34: error: invalid types 'int[int]' for array subscript
   41 |             ansyr = max(ansyr, vp[i].second);
      |                                  ^
a.cc:42:18: error: invalid types 'int[int]' for array subscript
   42 |             if(vp[i].second<0){
      |                  ^
a.cc:43:38: error: invalid types 'int[int]' for array subscript
   43 |                 ansyl = min(ansxd, vp[i].second);
      |                                      ^