Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> vec(H*W);

  for (int i = 0; i < H*W; i++) {
      char a;
      cin >> a;
      vec.at(i) = a;
    }
  int h = 0, w = 0;
  for (int i = H-1; i >= 0; i--) {
    for (int j = W-1; j >= 0; j--) {
      if (vec.at(i*W + j) == '#')
        break;
      else if (vec.at(i*W + j) == '.' && j > 0)
        continue;
      for (int k = 0; k < W; k++)
        vec.erase(i*W + (W-k-1));
      h--;
    }
  }
    
  for (int j = W-1; j >= 0; j--) {
    for (int i = H-h-1; i >= 0; i--) {
      if (vec.at(j + i*(W-w)) == '#')
        break;
      else if (vec.at(j + i*(W-w)) == '.' && i > 0)
        continue;
      for (int k = 0; k < H-h; k++)
        vec.erase(j + k*(W-w));
      w--;
    }
  }
        
  for (int i = 0; i < H-h; i++) {
    for (int j = 0; j < W-w; j++) {
      if (j != N-1)
        cout << vec.at(i).at(j+i*(W-w));
      else if (j == N-1)
        cout << vec.at(i).at(j+i*(W-w)) << endl;
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:18: error: no matching function for call to 'std::vector<char>::erase(int)'
   22 |         vec.erase(i*W + (W-k-1));
      |         ~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = char; _Alloc = std::allocator<char>; iterator = std::vector<char>::iterator; const_iterator = std::vector<char>::const_iterator]'
 1536 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:28: note:   no known conversion for argument 1 from 'int' to 'std::vector<char>::const_iterator'
 1536 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = char; _Alloc = std::allocator<char>; iterator = std::vector<char>::iterator; const_iterator = std::vector<char>::const_iterator]'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note:   candidate expects 2 arguments, 1 provided
a.cc:34:18: error: no matching function for call to 'std::vector<char>::erase(int)'
   34 |         vec.erase(j + k*(W-w));
      |         ~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = char; _Alloc = std::allocator<char>; iterator = std::vector<char>::iterator; const_iterator = std::vector<char>::const_iterator]'
 1536 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:28: note:   no known conversion for argument 1 from 'int' to 'std::vector<char>::const_iterator'
 1536 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = char; _Alloc = std::allocator<char>; iterator = std::vector<char>::iterator; const_iterator = std::vector<char>::const_iterator]'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note:   candidate expects 2 arguments, 1 provided
a.cc:41:16: error: 'N' was not declared in this scope
   41 |       if (j != N-1)
      |                ^
a.cc:42:27: error: request for member 'at' in 'vec.std::vector<char>::at(((std::vector<char>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'}
   42 |         cout << vec.at(i).at(j+i*(W-w));
      |                           ^~
a.cc:44:27: error: request for member 'at' in 'vec.std::vector<char>::at(((std::vector<char>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'}
   44 |         cout << vec.at(i).at(j+i*(W-w)) << endl;
      |                           ^~