Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define len(v) (int)(v).size()
#define show(x) cout << #x << " = " << x << "\n"

using namespace std;

const int MAX_N = 105;

int kind[MAX_N][MAX_N];

struct data
{
    int lx,ly,rx,ry;
    data(){}
    data(int a,int b,int c,int d) : lx(a), ly(b), rx(c), ry(d){}
};

int main()
{
    while(1){
        int n,w,h;
        cin >> n >> w >> h;
        if(n == 0 && w == 0 && h == 0){
            break;
        }
        vector<data> vec;
        vec.emplace_back(0,0,h,w);
        rep(i,h){
            rep(j,w){
                kind[i][j] = 0;
            }
        }
        rep(i,n){
            int p,s;
            cin >> p >> s;
            p--;
            data nw = vec[p];
            for(int j=p;j<len(vec)-1;j++){
                vec[j] = vec[j+1];
                for(int k=vec[j].lx;k<vec[j].rx;k++){
                    for(int l=vec[j].ly;l<vec[j].ry;l++){
                        kind[k][l] = j;
                    }
                }
            }
            int yoko = nw.ry-nw.ly;
            int tate = nw.rx-nw.lx;
            s %= 2*(yoko+tate);
            if(s < yoko){
                if(s <= yoko/2){
                    vec.back() = (data){nw.lx,nw.ly,nw.rx,nw.ly+s};
                    vec.emplace_back(nw.lx,nw.ly+s,nw.rx,nw.ry);
                    for(int j=nw.ly;j<s+nw.ly;j++){
                        for(int k=nw.lx;k<nw.rx;k++){
                            kind[k][j] = len(vec)-2;
                        }
                    }
                    for(int j=s+nw.ly;j<nw.ry;j++){
                        for(int k=nw.lx;k<nw.rx;k++){
                            kind[k][j] = len(vec)-1;
                        }
                    }
                }else{
                    vec.back() = (data){nw.lx,nw.ly+s,nw.rx,nw.ry};
                    vec.emplace_back(nw.lx,nw.ly,nw.rx,nw.ly+s);
                    for(int j=nw.ly;j<s+nw.ly;j++){
                        for(int k=nw.lx;k<nw.rx;k++){
                            kind[k][j] = len(vec)-1;
                        }
                    }
                    for(int j=s+nw.ly;j<nw.ry;j++){
                        for(int k=nw.lx;k<nw.rx;k++){
                            kind[k][j] = len(vec)-2;
                        }
                    }
                }
            }else if(s < tate+yoko){
                s -= yoko;
                if(s <= tate/2){
                    vec.back() = (data){nw.lx,nw.ly,nw.lx+s,nw.ry};
                    vec.emplace_back(nw.lx+s,nw.ly,nw.rx,nw.ry);
                    for(int j=nw.lx;j<nw.lx+s;j++){
                        for(int k=nw.ly;k<nw.ry;k++){
                            kind[j][k] = len(vec)-2;
                        }
                    }
                    for(int j=s+nw.lx;j<nw.rx;j++){
                        for(int k=nw.ly;k<nw.ly;k++){
                            kind[j][k] = len(vec)-1;
                        }
                    }
                }else{
                    vec.back() = (data){nw.lx+s,nw.ly,nw.rx,nw.ry};
                    vec.emplace_back(nw.lx,nw.ly,nw.lx+s,nw.ry);
                    for(int j=nw.lx;j<nw.lx+s;j++){
                        for(int k=nw.ly;k<nw.ry;k++){
                            kind[j][k] = len(vec)-1;
                        }
                    }
                    for(int j=s+nw.lx;j<nw.rx;j++){
                        for(int k=nw.ly;k<nw.ly;k++){
                            kind[j][k] = len(vec)-2;
                        }
                    }
                }
            }else if(s < tate+2*yoko){
                s -= tate+yoko;
                s = yoko-s;
                if(s <= yoko/2){
                    vec.back() = (data){nw.lx,nw.ly,nw.rx,nw.ly+s};
                    vec.emplace_back(nw.lx,nw.ly+s,nw.rx,nw.ry);
                    for(int j=nw.ly;j<s+nw.ly;j++){
                        for(int k=nw.lx;k<nw.rx;k++){
                            kind[k][j] = len(vec)-2;
                        }
                    }
                    for(int j=s+nw.ly;j<nw.ry;j++){
                        for(int k=nw.lx;k<nw.rx;k++){
                            kind[k][j] = len(vec)-1;
                        }
                    }
                }else{
                    vec.back() = (data){nw.lx,nw.ly+s,nw.rx,nw.ry};
                    vec.emplace_back(nw.lx,nw.ly,nw.rx,nw.ly+s);
                    for(int j=nw.ly;j<s+nw.ly;j++){
                        for(int k=nw.lx;k<nw.rx;k++){
                            kind[k][j] = len(vec)-1;
                        }
                    }
                    for(int j=s+nw.ly;j<nw.ry;j++){
                        for(int k=nw.lx;k<nw.rx;k++){
                            kind[k][j] = len(vec)-2;
                        }
                    }
                }
            }else{
                s -= 2*yoko+tate;
                s = tate-s;
                if(s <= tate/2){
                    vec.back() = (data){nw.lx,nw.ly,nw.lx+s,nw.ry};
                    vec.emplace_back(nw.lx+s,nw.ly,nw.rx,nw.ry);
                    for(int j=nw.lx;j<nw.lx+s;j++){
                        for(int k=nw.ly;k<nw.ry;k++){
                            kind[j][k] = len(vec)-2;
                        }
                    }
                    for(int j=s+nw.lx;j<nw.rx;j++){
                        for(int k=nw.ly;k<nw.ly;k++){
                            kind[j][k] = len(vec)-1;
                        }
                    }
                }else{
                    vec.back() = (data){nw.lx+s,nw.ly,nw.rx,nw.ry};
                    vec.emplace_back(nw.lx,nw.ly,nw.lx+s,nw.ry);
                    for(int j=nw.lx;j<nw.lx+s;j++){
                        for(int k=nw.ly;k<nw.ry;k++){
                            kind[j][k] = len(vec)-1;
                        }
                    }
                    for(int j=s+nw.lx;j<nw.rx;j++){
                        for(int k=nw.ly;k<nw.ly;k++){
                            kind[j][k] = len(vec)-2;
                        }
                    }
                }
            }
        }
        vector<int> ans(len(vec));
        rep(i,len(vec)){
            ans[i] = (vec[i].rx-vec[i].lx)*(vec[i].ry-vec[i].ly);
        }
        sort(ans.begin(),ans.end());
        rep(i,len(ans)-1){
            cout << ans[i] << " ";
        }
        cout << ans.back() << "\n";
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:27:20: error: template argument 1 is invalid
   27 |         vector<data> vec;
      |                    ^
a.cc:27:20: error: template argument 2 is invalid
a.cc:28:13: error: request for member 'emplace_back' in 'vec', which is of non-class type 'int'
   28 |         vec.emplace_back(0,0,h,w);
      |             ^~~~~~~~~~~~
a.cc:38:13: error: reference to 'data' is ambiguous
   38 |             data nw = vec[p];
      |             ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:12:8: note:                 'struct data'
   12 | struct data
      |        ^~~~
a.cc:3:25: error: request for member 'size' in 'vec', which is of non-class type 'int'
    3 | #define len(v) (int)(v).size()
      |                         ^~~~
a.cc:39:27: note: in expansion of macro 'len'
   39 |             for(int j=p;j<len(vec)-1;j++){
      |                           ^~~
a.cc:40:20: error: invalid types 'int[int]' for array subscript
   40 |                 vec[j] = vec[j+1];
      |                    ^
a.cc:40:29: error: invalid types 'int[int]' for array subscript
   40 |                 vec[j] = vec[j+1];
      |                             ^
a.cc:41:30: error: invalid types 'int[int]' for array subscript
   41 |                 for(int k=vec[j].lx;k<vec[j].rx;k++){
      |                              ^
a.cc:41:42: error: invalid types 'int[int]' for array subscript
   41 |                 for(int k=vec[j].lx;k<vec[j].rx;k++){
      |                                          ^
a.cc:42:34: error: invalid types 'int[int]' for array subscript
   42 |                     for(int l=vec[j].ly;l<vec[j].ry;l++){
      |                                  ^
a.cc:42:46: error: invalid types 'int[int]' for array subscript
   42 |                     for(int l=vec[j].ly;l<vec[j].ry;l++){
      |                                              ^
a.cc:47:24: error: 'nw' was not declared in this scope; did you mean 'w'?
   47 |             int yoko = nw.ry-nw.ly;
      |                        ^~
      |                        w
a.cc:52:25: error: request for member 'back' in 'vec', which is of non-class type 'int'
   52 |                     vec.back() = (data){nw.lx,nw.ly,nw.rx,nw.ly+s};
      |                         ^~~~
a.cc:52:35: error: reference to 'data' is ambiguous
   52 |                     vec.back() = (data){nw.lx,nw.ly,nw.rx,nw.ly+s};
      |                                   ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:12:8: note:                 'struct data'
   12 | struct data
      |        ^~~~
a.cc:53:25: error: request for member 'emplace_back' in 'vec', which is of non-class type 'int'
   53 |                     vec.emplace_back(nw.lx,nw.ly+s,nw.rx,nw.ry);
      |                         ^~~~~~~~~~~~
a.cc:3:25: error: request for member 'size' in 'vec', which is of non-class type 'int'
    3 | #define len(v) (int)(v).size()
      |                         ^~~~
a.cc:56:42: note: in expansion of macro 'len'
   56 |                             kind[k][j] = len(vec)-2;
      |                                          ^~~
a.cc:3:25: error: request for member 'size' in 'vec', which is of non-class type 'int'
    3 | #define len(v) (int)(v).size()
      |                         ^~~~
a.cc:61:42: note: in expansion of macro 'len'
   61 |                             kind[k][j] = len(vec)-1;
      |                                          ^~~
a.cc:65:25: error: request for member 'back' in 'vec', which is of non-class type 'int'
   65 |                     vec.back() = (data){nw.lx,nw.ly+s,nw.rx,nw.ry};
      |                         ^~~~
a.cc:65:35: error: reference to 'data' is ambiguous
   65 |                     vec.back() = (data){nw.lx,nw.ly+s,nw.rx,nw.ry};
      |                                   ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:12:8: note:                 'struct data'
   12 | struct data
      |        ^~~~
a.cc:66:25: error: request for member 'emplace_back' in 'vec', which is of non-class type 'int'
   66 |                     vec.emplace_back(nw.lx,nw.ly,nw.rx,nw.ly+s);
      |                         ^~~~~~~~~~~~
a.cc:3:25: error: request for member 'size' in 'vec', which is of non-class type 'int'
    3 | #define len(v) (int)(v).size()
      |                         ^~~~
a.cc:69:42: note: in expansion of macro 'len'
   69 |                             kind[k][j] = len(vec)-1;
      |                                          ^~~
a.cc:3:25: error: request for member 'size' in 'vec', which is of non-class type 'int'
    3 | #define len(v) (int)(v).size()
      |                         ^~~~
a.cc:74:42: note: in expansion of macro 'len'
   74 |                             kind[k][j] = len(vec)-2;
      |                                          ^~~
a.cc:81:25: error: request for member 'back' in 'vec', which is of non-class type 'int'
   81 |                     vec.back() = (data){nw.lx,nw.ly,nw.lx+s,nw.ry};
      |                         ^~~~
a.cc:81:35: error: reference to 'data' is ambiguous
   81 |                     vec.back() = (data){nw.lx,nw.ly,nw.lx+s,nw.ry};
      |                                   ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:12:8: note:                 'struct data'
   12 | struct data
      |        ^~~~
a.cc:82:25: error: request for member 'emplace_back' in 'vec', which is of non-class type 'int'
   82 |                     vec.emplace_back(nw.lx+s,nw.ly,nw.rx,nw.ry);
      |                         ^~~~~~~~~~~~
a.cc:3:25: error: request for member 'size' in 'vec', which is of non-class type 'int'
    3 | #define len(v) (int)(v).size()
      |                         ^~~~
a.cc:85:42: note: in expansion of macro 'len'
   85 |                             kind[j][k] = len(vec)-2;
      |                                          ^~~
a.cc:3:25: error: request for member 'size' in 'vec', which is of non-class type 'int'
    3 | #define len(v) (int)(v).size()
      |                         ^~~~
a.cc:90:42: note: in expansion of macro 'len'
   90 |                             kind[j][k] = len(vec)-1;
      |                                          ^~~
a.cc:94:25: error: request for member 'back' in 'vec', which is of non-class type 'int'
   94 |                     vec.back() = (data){nw.lx+s,nw.ly,nw.rx,nw.ry};
      |                         ^~~~
a.cc:94:35: error: reference to 'data' is ambiguous
   94 |                     vec.back() =