Language: C++

#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
using namespace std;

class cp{
private:
  int r,i;
public:
  cp(int re,int im){
    r=re; i=im;
  }
  cp(){
    r=i=0;
  }
  int real(){
    return r;
  }
  int imag(){
    return i;
  }
}

cp conj(cp z){
  return cp(z.real(),-z.imag());
}

bool cp(const cp& a, const cp& b){
  return (a.real()<b.real())||(a.real()==b.real() && a.imag()<b.imag());
}

int area(cp z0,cp z1,cp z2){
  return (conj(z0-z1)*(z2-z1)).imag();
}

int main(){
  int n;
  cin >> n;
  vector<cp > v;

  for(int i=0;i<n;i++){
    int x,y;
    cin >> x >> y;
    v.push_back(cp(x,y));
  }

  sort(v.begin(),v.end(),cp);

  vector<cp > u,b;
  int i;
  for(i=0;v[i].real()==v[0].real();i++) ;
  u.push_back(v[0]);
  b.push_back(v[0]);


  int j=1;
  while(u.back().real()!=v.back().real()){
    u.push_back(v[j]);	//??\????????????
    int l=u.size();

//l=2 ??? (l>3and(u[l-2]-u[l-3]???u[l-1]-u[l-2]???????§???\???))??????OK
//???????????°?¬????????????????????????????????????????????????????????????´???

    if(l==2) j++;
    else if(area(u[l-3],u[l-2],u[l-1])>=0.0) j++;
    else{
      u.pop_back();
      u.pop_back();
    }
  }
  u.pop_back();
  u.push_back(v[n-1]);

  j=i;
  while(b.back()!=v.back()){
    b.push_back(v[j]);	//??\????????????
    int l=b.size();

//l=2 ??? (l>3and(b[l-2]-b[l-3]???b[l-1]-b[l-2]???????§???\???))??????OK
//???????????°?¬????????????????????????????????????????????????????????????´???

    if(l==2) j++;
    else if(area(b[l-3],b[l-2],b[l-1])<=0.0) j++;
    else{
      b.pop_back();
      b.pop_back();
    }
  }

  if(u.back()==b.back()) b.pop_back();

  vector<cp > ru;
  for(int k=0;k<u.size();k++)
    ru.push_back(u[u.size()-1-k]);

  if(ru.back()==b.front()) ru.pop_back();

  b.insert(b.end(),ru.begin(),ru.end());

  for(i=b.size();i<b.size()*2;i++)
    if(b[(i-1)%b.size()].imag()>b[i%b.size()].imag() && b[i%b.size()].imag()<=b[(i+1)%b.size()].imag())
      break;

  cout << b.size() << endl;
  for(int k=0;k<b.size();k++)
    cout << b[(i+k)%b.size()].real() << ' ' << b[(i+k)%b.size()].imag() << endl;
  
  return 0;
}

Compiler output:
a.cc:25:4: error: expected initializer before 'conj'
   25 | cp conj(cp z){
      |    ^~~~
a.cc: In function 'bool cp(const cp&, const cp&)':
a.cc:30:17: error: passing 'const cp' as 'this' argument discards qualifiers [-fpermissive]
   30 |   return (a.real()<b.real())||(a.real()==b.real() && a.imag()<b.imag());
      |           ~~~~~~^~
a.cc:17:7: note:   in call to 'int cp::real()'
   17 |   int real(){
      |       ^~~~
a.cc:30:26: error: passing 'const cp' as 'this' argument discards qualifiers [-fpermissive]
   30 |   return (a.real()<b.real())||(a.real()==b.real() && a.imag()<b.imag());
      |                    ~~~~~~^~
a.cc:17:7: note:   in call to 'int cp::real()'
   17 |   int real(){
      |       ^~~~
a.cc:30:38: error: passing 'const cp' as 'this' argument discards qualifiers [-fpermissive]
   30 |   return (a.real()<b.real())||(a.real()==b.real() && a.imag()<b.imag());
      |                                ~~~~~~^~
a.cc:17:7: note:   in call to 'int cp::real()'
   17 |   int real(){
      |       ^~~~
a.cc:30:48: error: passing 'const cp' as 'this' argument discards qualifiers [-fpermissive]
   30 |   return (a.real()<b.real())||(a.real()==b.real() && a.imag()<b.imag());
      |                                          ~~~~~~^~
a.cc:17:7: note:   in call to 'int cp::real()'
   17 |   int real(){
      |       ^~~~
a.cc:30:60: error: passing 'const cp' as 'this' argument discards qualifiers [-fpermissive]
   30 |   return (a.real()<b.real())||(a.real()==b.real() && a.imag()<b.imag());
      |                                                      ~~~~~~^~
a.cc:20:7: note:   in call to 'int cp::imag()'
   20 |   int imag(){
      |       ^~~~
a.cc:30:69: error: passing 'const cp' as 'this' argument discards qualifiers [-fpermissive]
   30 |   return (a.real()<b.real())||(a.real()==b.real() && a.imag()<b.imag());
      |                                                               ~~~~~~^~
a.cc:20:7: note:   in call to 'int cp::imag()'
   20 |   int imag(){
      |       ^~~~
a.cc: At global scope:
a.cc:33:12: error: expected ')' before 'z0'
   33 | int area(cp z0,cp z1,cp z2){
      |         ~  ^~~
      |            )
a.cc:33:18: error: expected ')' before 'z1'
   33 | int area(cp z0,cp z1,cp z2){
      |         ~        ^~~
      |                  )
a.cc:33:24: error: expected ')' before 'z2'
   33 | int area(cp z0,cp z1,cp z2){
      |         ~              ^~~
      |                        )
a.cc:33:27: error: expression list treated as compound expression in initializer [-fpermissive]
   33 | int area(cp z0,cp z1,cp z2){
      |                           ^
a.cc:33:27: error: invalid conversion from 'bool (*)(const cp&, const cp&)' to 'int' [-fpermissive]
   33 | int area(cp z0,cp z1,cp z2){
      |                           ^
      |                           |
      |                           bool (*)(const cp&, const cp&)
a.cc:33:28: error: expected ',' or ';' before '{' token
   33 | int area(cp z0,cp z1,cp z2){
      |                            ^
a.cc: In function 'int main()':
a.cc:40:13: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   40 |   vector<cp > v;
      |             ^
a.cc:40:13: note:   expected a type, got 'cp'
a.cc:40:13: error: template argument 2 is invalid
a.cc:45:7: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   45 |     v.push_back(cp(x,y));
      |       ^~~~~~~~~
a.cc:45:20: error: invalid initialization of reference of type 'const cp&' from expression of type 'int'
   45 |     v.push_back(cp(x,y));
      |                    ^
a.cc:29:19: note: in passing argument 1 of 'bool cp(const cp&, const cp&)'
   29 | bool cp(const cp& a, const cp& b){
      |         ~~~~~~~~~~^
a.cc:48:10: error: request for member 'begin' in 'v', which is of non-class type 'int'
   48 |   sort(v.begin(),v.end(),cp);
      |          ^~~~~
a.cc:48:20: error: request for member 'end' in 'v', which is of non-class type 'int'
   48 |   sort(v.begin(),v.end(),cp);
      |                    ^~~
a.cc:50:13: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   50 |   vector<cp > u,b;
      |             ^
a.cc:50:13: note:   expected a type, got 'cp'
a.cc:50:13: error: template argument 2 is invalid
a.cc:52:12: error: invalid types 'int[int]' for array subscript
   52 |   for(i=0;v[i].real()==v[0].real();i++) ;
      |            ^
a.cc:52:25: error: invalid types 'int[int]' for array subscript
   52 |   for(i=0;v[i].real()==v[0].real();i++) ;
      |                         ^
a.cc:53:5: error: request for member 'push_back' in 'u', which is of non-class type 'int'
   53 |   u.push_back(v[0]);
      |     ^~~~~~~~~
a.cc:53:16: error: invalid types 'int[int]' for array subscript
   53 |   u.push_back(v[0]);
      |                ^
a.cc:54:5: error: request for member 'push_back' in 'b', which is of non-class type 'int'
   54 |   b.push_back(v[0]);
      |     ^~~~~~~~~
a.cc:54:16: error: invalid types 'int[int]' for array subscript
   54 |   b.push_back(v[0]);
      |                ^
a.cc:58:11: error: request for member 'back' in 'u', which is of non-class type 'int'
   58 |   while(u.back().real()!=v.back().real()){
      |           ^~~~
a.cc:58:28: error: request for member 'back' in 'v', which is of non-class type 'int'
   58 |   while(u.back().real()!=v.back().real()){
      |                            ^~~~
a.cc:59:7: error: request for member 'push_back' in 'u', which is of non-class type 'int'
   59 |     u.push_back(v[j]);  //??\????????????
      |       ^~~~~~~~~
a.cc:59:18: error: invalid types 'int[int]' for array subscript
   59 |     u.push_back(v[j]);  //??\????????????
      |                  ^
a.cc:60:13: error: request for member 'size' in 'u', which is of non-class type 'int'
   60 |     int l=u.size();
      |             ^~~~
a.cc:66:19: error: invalid types 'int[int]' for array subscript
   66 |     else if(area(u[l-3],u[l-2],u[l-1])>=0.0) j++;
      |                   ^
a.cc:66:26: error: invalid types 'int[int]' for array subscript
   66 |     else if(area(u[l-3],u[l-2],u[l-1])>=0.0) j++;
      |                          ^
a.cc:66:33: error: invalid types 'int[int]' for array subscript
   66 |     else if(area(u[l-3],u[l-2],u[l-1])>=0.0) j++;
      |                                 ^
a.cc:66:38: error: 'area' cannot be used as a function
   66 |     else if(area(u[l-3],u[l-2],u[l-1])>=0.0) j++;
      |                                      ^
a.cc:68:9: error: request for member 'pop_back' in 'u', which is of non-class type 'int'
   68 |       u.pop_back();
      |         ^~~~~~~~
a.cc:69:9: error: request for member 'pop_back' in 'u', which is of non-class type 'int'
   69 |       u.pop_back();
      |         ^~~~~~~~
a.cc:72:5: error: request for member 'pop_back' in 'u', which is of non-class type 'int'
   72 |   u.pop_back();
      |     ^~~~~~~~
a.cc:73:5: error: request for member 'push_back' in 'u', which is of non-class type 'int'
   73 |   u.push_back(v[n-1]);
      |     ^~~~~~~~~
a.cc:73:16: error: invalid types 'int[int]' for array subscript
   73 |   u.push_back(v[n-1]);
      |                ^
a.cc:76:11: error: request for member 'back' in 'b', which is of non-class type 'int'
   76 |   while(b.back()!=v.back()){
      |           ^~~~
a.cc:76:21: error: request for member 'back' in 'v', which is of non-class type 'int'
   76 |   while(b.back()!=v.back()){
      |                     ^~~~
a.cc:77:7: error: request for member 'push_back' in 'b', which is of non-class type 'int'
   77 |     b.push_back(v[j]);  //??\????????????
      |       ^~~~~~~~~
a.cc:77:18: error: invalid types 'int[int]' for array subscript
   77 |     b.push_back(v[j]);  //??\????????????
      |                  ^
a.cc:78:13: error: request for member 'size' in 'b', which is of non-class type 'int'
   78 |     int l=b.size();
      |             ^~~~
a.cc:84:19: error: invalid types 'int[int]' for array subscript
   84 |     else if(area(b[l-3],b[l-2],b[l-1])<=0.0) j++;
      |                   ^
a.cc:84:26: error: invalid types 'int[int]' for array subscript
   84 |     else if(area(b[l-3],b[l-2],b[l-1])<=0.0) j++;
      |                          ^
a.cc:84:33: error: invalid types 'int[int]' for array subscript
   84 |     else if(area(b[l-3],b[l-2],b[l-1])<=0.0) j++;
      |                                 ^
a.cc:84:38: error: 'area' cannot be used as a function
   84 |     else if(area(b[l-3],b[l-2],b[l-1])<=0.0) j++;
      |                                      ^
a.cc:86:9: error: request for member 'pop_back' in 'b', which is of non-class type 'int'
   86 |       b.pop_back();
      |         ^~~~~~~~
a.cc:87:9: error: request for member 'pop_back' in 'b', which is of non-class type 'int'
   87 |       b.pop_back();
      |         ^~~~~~~~
a.cc:91:8: error: request for member 'back' in 'u', which is of non-class type 'int'
   91 |   if(u.back()==b.back()) b.pop_back();
      |        ^~~~
a.cc:91:18: error: request for member 'back' in 'b', which is of non-class type 'int'
   91 |   if(u.back()==b.back()) b.pop_back();
      |                  ^~~~
a.cc:91:28: error: request for member 'pop_back' in 'b', which is of non-class type 'int'
   91 |   if(u.back()==b.back()) b.pop_back();
      |                            ^~~~~~~~
a.cc:93:13: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   93 |   vector<cp > ru;
      |             ^
a.cc:93:13: note:   expected a type, got 'cp'
a.cc:93:13: error: template argument 2 is invalid
a.cc:94:19: error: request for member 'size' in 'u', which is of non-class type 'int'
   94 |   for(int k=0;k<u.size();k++)
      |                   ^~~~
a.cc:95:8: error: request for member 'push_back' in 'ru', which is of non-class type 'int'
   95 |     ru.push_back(u[u.size()-1-k]);
      |        ^~~~~~~~~
a.cc:95:22: error: request for member 'size' in 'u', which is of non-class type 'int'
   95 |     ru.push_back(u[u.size()-1-k]);
      |                      ^~~~
a.cc:97:9: error: request for member