failure_forever's blog

By failure_forever, history, 9 months ago, In English

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;

}

Full text and comments »

  • Vote: I like it
  • -6
  • Vote: I do not like it

By failure_forever, history, 13 months ago, In English

I have a doubt that whether there will be Gwalior-Pune regionals this year??

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it

By failure_forever, history, 13 months ago, In English

Can anyone tell me how to do this question: Binary Number. What is the intuition behind?

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it

By failure_forever, history, 13 months ago, In English

Can someone explain how to do this Soldier and cards according to the method given in editorial . I have done this question using deque but I want a approach as followed in editorial.

Any help is much appreciated.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By failure_forever, history, 14 months ago, In English

Hello folks!!

I want to understand how to approach the problems where we have to do some sort of operations on array. For example swap some elements such that array becomes increasing . Something like this . I find it difficult that how to pick the operations and perform them optimally. I would be highly obliged for valuable tips and suggestions .

Regards

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it