Codeforces Round #644 (Div. 3) 1360E - Polygon Solution



 Problem Link: https://codeforces.com/problemset/problem/1360/E

Solution in C++:

///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat  Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll  n,t,i,j,f;
    bool a[55][55];
    cin>>t;
    while(t--)
    {
        f=0;
        cin>>n;
        for(i=1; i<=n; i++)
        {
            for(j=1; j<=n; j++)
            {
                char c;
                cin>>c;
                a[i][j]=c-'0';
            }
        }
        for(i=1; i<n; i++)
        {
            for(j=1; j<n; j++)
            {
                if(a[i][j]==1&&a[i][j+1]==0&&a[i+1][j]==0)
                {
                    f=1;
                    break;
                }
            }
        }
        if(f==0)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}





No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.