Skip to main content

Codeforces Round #817 (Div. 4) (F. L-shapes)

Bismillahir Rahmanir Rahim

When find the sign(*) just travarse all its up,down,both side & 4 courner 
neighbour and checked weather a L shape is formed or not.

///Author: Tanvir Ahmmad
///CSE,Islamic University,Bangladesh

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<vector>
#include<iterator>
#include <functional> ///sort(arr,arr+n,greater<int>()) for decrement of array
/*every external angle sum=360 degree
  angle find using polygon hand(n) ((n-2)*180)/n*/
///Floor[Log(b)  N] + 1 = the number of digits when any number is represented in base b
using namespace std;
typedef long long ll;

int xxz[]= {-1,-1,-1,0,0,1,1,1};
int yyz[]= {-1,0,1,-1,1,-1,0,1};
bool vis[55][55];
string str[55];

bool chk(ll ki,ll kj,ll n,ll m)
{
    ll arr_x=0,arr_y=0,pos=1;
    for(ll i=0; i<8; i++)
    {
        ll new_x=xxz[i]+ki;
        ll new_y=yyz[i]+kj;
        if(vis[new_x][new_y]==false && (new_x>=0 && new_x<n) && (new_y>=0 && new_y<m))
        {
            pos++;
            arr_x+=xxz[i];
            arr_y+=yyz[i];
        }
    }
    if(pos==3 && arr_x!=0 && arr_y!=0)
        return true;
    else
        return false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll tst,n,m;
    cin>>tst;
    while(tst--)
    {
        bool flag=true;
        cin>>n>>m;

        for(ll i=0; i<n; i++)
            cin>>str[i];
        for(ll i=0; i<n; i++)
            for(ll j=0; j<m; j++)
            {
                if(str[i][j]=='.')
                    vis[i][j]=true;
                else
                    vis[i][j]=false;
            }
        for(ll i=0; i<n; i++)
            for(ll j=0; j<m; j++)
                if(str[i][j]=='*' && flag==true)
                    flag=chk(i,j,n,m);

        if(flag)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}
///Alhamdulillah

Problem Link: https://codeforces.com/problemset/problem/1722/F

Comments

Popular posts from this blog

Codeforces round 1676(A. Lucky?)

Just count the  first three  &  last three  number ///Bismillahir Rahmanir Rahim ///Author: Tanvir Ahmmad ///CSE,Islamic University,Bangladesh #include< iostream > #include< cstdio > #include< algorithm > #include< string > #include< cstring > #include< sstream > #include< cmath > #include< cstring > #include< vector > #include< queue > #include< map > #include< set > #include< stack > #include< vector > #include< iterator > #include   < functional >   ///sort(arr,arr+n,greater<int>()) for decrement of array /*every external angle sum=360 degree   angle find using polygon hand(n) ((n-2)*180)/n*/ ///Floor[Log(b)  N] + 1 = the number of digits when any number is repres...

Codeforces round 1661(B. Getting Zero)

using   second operation  the answer is maximum is  15  because  2 15 =32768 so we need to  pre-calculate all the illegible input 0 to 32768   using  second operation Then  just increment 1(using first operation)  from input check is it  minimum is not ! ///Bismillahir Rahmanir Rahim ///Author: Tanvir Ahmmad ///CSE,Islamic University,Bangladesh #include< iostream > #include< cstdio > #include< algorithm > #include< string > #include< cstring > #include< sstream > #include< cmath > #include< cstring > #include< vector > #include< queue > #include< map > #include< set > #include< stack > #include< vector > #include< iterator > #include   < functional >   ///sort(arr,arr+n,greater<int...

Codeforces round 1676(E. Eating Queries)

Just use the lower bound & check is it greater than the sum or not Lower bound:https://www.geeksforgeeks.org/upper_bound-and-lower_bound- for -vector- in -cpp-stl/ ///Bismillahir Rahmanir Rahim ///Author: Tanvir Ahmmad ///CSE,Islamic University,Bangladesh #include< iostream > #include< cstdio > #include< algorithm > #include< string > #include< cstring > #include< sstream > #include< cmath > #include< cstring > #include< vector > #include< queue > #include< map > #include< set > #include< stack > #include< vector > #include< iterator > #include   < functional >   ///sort(arr,arr+n,greater<int>()) for decrement of array /*every external angle sum=360 degree   angle find using polygon hand(n) ((n-2)*180...