Codeforces Round #777 (Div. 2) 1647B - Madoka and the Elegant Gift

 





Problem Link:  https://codeforces.com/contest/1647/problem/B

Solution in C++:

///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat  Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,m,i,j,c,ans;
        c=ans=0;
        cin>>n>>m;
        char s[200][200];
        for(i=1; i<=n; i++)
        {
            cin>>s[i];
        }
        for(i=1; i<=n; i++)
        {
            for(j=1; j<=m; j++)
            {
                c=0;
                if(s[i][j]=='1')
                    c++;
                if(s[i][j-1]=='1')
                    c++;
                if(s[i-1][j]=='1')
                    c++;
                if(s[i-1][j-1]=='1')
                    c++;
                if(c==3)
                {
                    ans=1;
                }
            }
        }
        if(ans==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 &g...

Powered by Blogger.