Please read the new rule regarding the restriction on the use of AI tools. ×
Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Help needed for a question

Revision en1, by failure_forever, 2023-07-22 18:04:27

can anyone help what is wrong in my this code for atcoder question Atcoder D

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

const int N=201;
char arr[N][N];
int dr[]={-1,0,1,0};
int dc[]={0,1,0,-1};
int vis[N][N];
void dfs(int i,int j,vector<int> &v,int c)
{
    if(vis[i][j]==1)
        return;

    vis[i][j]=1;
    c++;
    for(int k=0;k<4;k++)
    {
        int x=i+dr[k];
        int y=j+dc[k];
        if(vis[x][y]==0 and arr[x][y]=='.')
        {
            dfs(x,y,v,c);

        }
        else
        {
            v.push_back(c);
        }

    }



}



int32_t main()
{
       ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);

    #endif
    int n,m;
    cin>>n>>m;
    ::memset(arr,'/',sizeof  arr);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++) cin>>arr[i][j];
    vector<int> hell;
    dfs(1,1,hell,0);
   cout<<*max_element(hell.begin(),hell.end())<<endl;

}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English failure_forever 2023-07-22 18:04:27 1207 Initial revision (published)