タグ » A

BFS Problems

Problem Name : Labyrinth
Problem Link : https://codeforces.com/contest/1064/problem/D
Solution :

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

#define ll           long long
#define pii          pair<ll,ll>
#define bug(a)       cerr << #a << " : " << a << endl;
#define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

const int MAX = 2e3+5;

int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,-1,1};

char ch;
int n,m,r,c,x,y,cnt;
int dist1, dist2;

struct data
{
    int i,j;
    data() {}
    data(int _i,int _j)
    {
        i = _i;
        j = _j;
    }
};

bool isValid(int xx,int yy)
{
    if(xx >= 1 && xx <= n && yy >= 1 && yy <= m && ch == '.')
        return 1;
    return 0;
}
void BFS(int i,int j)
{
    queue<data>q;

    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
            dist1[i][j] = dist2[i][j] = 2e9;

    q.push(data(i,j));

    dist1[i][j] = dist2[i][j] = 0;

    while(!q.empty())
    {
        data u = q.front();
        q.pop();

        for(int i=0; i<4; i++)
        {
            int xx = u.i+dx[i], yy = u.j+dy[i] , f1 = 0 , f2 = 0;

            f1 = (i == 2 ? さらに143語
Latest Posts

Pizzamandens psykolog, solskin og ekstra chilimayo.

I frygt for at jinxe det, tør jeg næsten ikke sige det, men hold op, et lækkert efterårsvejr, vi har os.

Forrige uge har derfor gået med alt del udetid, jeg kunne hamstre. さらに311語

Der Er Altid Noget At Fejre

Friday night was a complete reset for me. I’ve never really put into words what a reset looks like for me and why A is such a big part of them.   さらに1,623語

Relationships

Vintage Style Light Up Letter

Hey guys, so I wanted to share with you all another item that I found on Amazon. I really wanted something silver that would again, match my silver mirrors and grey fur pillow. さらに44語

Dorm Inspiration

Radical Blogging is one year old today!

Today is 14th October, 2018, meaning that though Photography of thoughts is way older Radical Blogging is one year old today, hallelujah!

It’s been one year of doing something I never dreamed of doing and being successful at, isn’t God amazing? さらに1,180語

E

Nominees For The 3rd Edition Of GIJ Eminence Awards Unveiled

The third edition of the GIJ Eminence Awards, which is to recognize, inspire and encourage positive works of students was launched on September, 13th 2018, and Today Saturday, October 13th announced the list of students nominated. さらに444語

E

Fem bøger, jeg altid vender tilbage til.

Modsat mange, jeg kender, er jeg helt tosset med at genlæse bøger. Mange gange. Jeg kan møde nogle, der reklamere for en roman ved at sige “den er så god, jeg faktisk har overvejet, at læse den en gang til!” さらに965語

A