# ISREC - Editorial

**URL:** <https://discuss.codechef.com/t/isrec-editorial/86007>\
**Category:** editorial\
**Tags:** easy, editorial, observation, ccrc2021\
**Created:** [February 24, 2021, 6:21pm UTC](https://discuss.codechef.com/t/isrec-editorial/86007 "2021-02-24T18:21:36Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![pranjalpatel23](https://discuss.codechef.com/user_avatar/discuss.codechef.com/pranjalpatel23/32/93617_2.png) [@pranjalpatel23](https://discuss.codechef.com/u/pranjalpatel23)\
**Post date:** [February 26, 2021, 7:20am UTC](https://discuss.codechef.com/t/isrec-editorial/86007/17 "2021-02-26T07:20:28Z")

</div>

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

int main() {  
int t;  
cin\>\>t;  
while(t–)  
{  
int n,m;  
cin\>\>n\>\>m;  
string arr[10000000];  
int count=0;  
vector\<pair\<int,int\>\>v;

```
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        for(int j=0;j<m;j++)
        {
            if(arr[i][j]=='1')
            {
                v.push_back({i,j});
                count++;
               
            }
        }
    }
    int a = v[0].first;
    int b = v[v.size()-1].first;
    int c = v[0].second;
    int d = v[v.size()-1].second;
    int k=(abs(b-a)+1)*(abs(c-d)+1);
    int sum=0;
    
    
    for(int i=0;i<count;i++)
    {
        if((min(a,b)<=v[i].first && max(a,b)>=v[i].first && min(c,d)<=v[i].second && max(c,d)>=v[i].second))
           {
               sum++;
           }
             
    }
    if(sum==count)
    {
        cout<<"YES"<<"\n";
    }
    else
    {
        cout<<"NO"<<"\n";
    }
    
    
    
    
    
    
    
    
}

```

}

whats wrong in thi solution…i am counting total number of cells between left most and right most…and equating it to total number of 1s…nd making sure all 1s lie between top left most and bottom right most

---

_[View the full topic](https://discuss.codechef.com/t/isrec-editorial/86007)._
