Language: C++

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

int sousa(int i,int j,char *c,int cnt){
  if((c[i][j])=='.'){
    if(i>0){
      if(j>0){
        return max({sousa(c,i-1,j,cnt+1),sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      }else{
        return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i-1,j,cnt+1)});
      }
    }else{
      if(j>0){
        return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      }else{
        return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1)});
      }
    }
  }else{
    return cnt;
  }
}
  
        

int main(){
  int h, w;
  cin >> h >> w;
  char c[h][w];
  int i,j;
  for(i=0;i<h;i++) for(j=0;j<w;j++) cin >> c[i][j];
  int ans = 0;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      ans = max(ans,sousa(i,j,c,0));
    }
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int sousa(int, int, char*, int)':
a.cc:6:11: error: invalid types 'char[int]' for array subscript
    6 |   if((c[i][j])=='.'){
      |           ^
a.cc:9:27: error: invalid conversion from 'char*' to 'int' [-fpermissive]
    9 |         return max({sousa(c,i-1,j,cnt+1),sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                           ^
      |                           |
      |                           char*
a.cc:5:15: note:   initializing argument 1 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |           ~~~~^
a.cc:9:33: error: invalid conversion from 'int' to 'char*' [-fpermissive]
    9 |         return max({sousa(c,i-1,j,cnt+1),sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                                 ^
      |                                 |
      |                                 int
a.cc:5:29: note:   initializing argument 3 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |                       ~~~~~~^
a.cc:9:48: error: invalid conversion from 'char*' to 'int' [-fpermissive]
    9 |         return max({sousa(c,i-1,j,cnt+1),sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                                                ^
      |                                                |
      |                                                char*
a.cc:5:15: note:   initializing argument 1 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |           ~~~~^
a.cc:9:54: error: invalid conversion from 'int' to 'char*' [-fpermissive]
    9 |         return max({sousa(c,i-1,j,cnt+1),sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                                                      ^
      |                                                      |
      |                                                      int
a.cc:5:29: note:   initializing argument 3 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |                       ~~~~~~^
a.cc:9:69: error: invalid conversion from 'char*' to 'int' [-fpermissive]
    9 |         return max({sousa(c,i-1,j,cnt+1),sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                                                                     ^
      |                                                                     |
      |                                                                     char*
a.cc:5:15: note:   initializing argument 1 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |           ~~~~^
a.cc:9:74: error: invalid conversion from 'int' to 'char*' [-fpermissive]
    9 |         return max({sousa(c,i-1,j,cnt+1),sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                                                                         ~^~
      |                                                                          |
      |                                                                          int
a.cc:5:29: note:   initializing argument 3 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |                       ~~~~~~^
a.cc:9:90: error: invalid conversion from 'char*' to 'int' [-fpermissive]
    9 |         return max({sousa(c,i-1,j,cnt+1),sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                                                                                          ^
      |                                                                                          |
      |                                                                                          char*
a.cc:5:15: note:   initializing argument 1 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |           ~~~~^
a.cc:9:95: error: invalid conversion from 'int' to 'char*' [-fpermissive]
    9 |         return max({sousa(c,i-1,j,cnt+1),sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                                                                                              ~^~
      |                                                                                               |
      |                                                                                               int
a.cc:5:29: note:   initializing argument 3 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |                       ~~~~~~^
a.cc:11:27: error: invalid conversion from 'char*' to 'int' [-fpermissive]
   11 |         return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i-1,j,cnt+1)});
      |                           ^
      |                           |
      |                           char*
a.cc:5:15: note:   initializing argument 1 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |           ~~~~^
a.cc:11:33: error: invalid conversion from 'int' to 'char*' [-fpermissive]
   11 |         return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i-1,j,cnt+1)});
      |                                 ^
      |                                 |
      |                                 int
a.cc:5:29: note:   initializing argument 3 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |                       ~~~~~~^
a.cc:11:48: error: invalid conversion from 'char*' to 'int' [-fpermissive]
   11 |         return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i-1,j,cnt+1)});
      |                                                ^
      |                                                |
      |                                                char*
a.cc:5:15: note:   initializing argument 1 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |           ~~~~^
a.cc:11:53: error: invalid conversion from 'int' to 'char*' [-fpermissive]
   11 |         return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i-1,j,cnt+1)});
      |                                                    ~^~
      |                                                     |
      |                                                     int
a.cc:5:29: note:   initializing argument 3 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |                       ~~~~~~^
a.cc:11:69: error: invalid conversion from 'char*' to 'int' [-fpermissive]
   11 |         return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i-1,j,cnt+1)});
      |                                                                     ^
      |                                                                     |
      |                                                                     char*
a.cc:5:15: note:   initializing argument 1 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |           ~~~~^
a.cc:11:75: error: invalid conversion from 'int' to 'char*' [-fpermissive]
   11 |         return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i-1,j,cnt+1)});
      |                                                                           ^
      |                                                                           |
      |                                                                           int
a.cc:5:29: note:   initializing argument 3 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |                       ~~~~~~^
a.cc:15:27: error: invalid conversion from 'char*' to 'int' [-fpermissive]
   15 |         return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                           ^
      |                           |
      |                           char*
a.cc:5:15: note:   initializing argument 1 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |           ~~~~^
a.cc:15:33: error: invalid conversion from 'int' to 'char*' [-fpermissive]
   15 |         return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                                 ^
      |                                 |
      |                                 int
a.cc:5:29: note:   initializing argument 3 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |                       ~~~~~~^
a.cc:15:48: error: invalid conversion from 'char*' to 'int' [-fpermissive]
   15 |         return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                                                ^
      |                                                |
      |                                                char*
a.cc:5:15: note:   initializing argument 1 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |           ~~~~^
a.cc:15:53: error: invalid conversion from 'int' to 'char*' [-fpermissive]
   15 |         return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                                                    ~^~
      |                                                     |
      |                                                     int
a.cc:5:29: note:   initializing argument 3 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |                       ~~~~~~^
a.cc:15:69: error: invalid conversion from 'char*' to 'int' [-fpermissive]
   15 |         return max({sousa(c,i+1,j,cnt+1),sousa(c,i,j+1,cnt+1),sousa(c,i,j-1,cnt+1)});
      |                                                                     ^
      |                                                                     |
      |                                                                     char*
a.cc:5:15: note:   initializing argument 1 of 'int sousa(int, int, char*, int)'
    5 | int sousa(int i,int j,char *c,int cnt){
      |           ~~~~^
a.cc:15:74: error: invalid conversion f