General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
54663882 Practice:
x_YZ
1162B - 39 C++14 (GCC 6-32) Wrong answer on test 7 31 ms 72 KB 2019-05-26 15:10:10 2019-05-26 15:10:10
→ Source
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long int i,j,n,m,y,z,flag=0;
    unsigned long long int k=0;
    unsigned long long int a[50][50],b[50][50],c[50][50],d[50][50];

    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cin>>b[i][j];
        }
    }
    
    c[0][0]=min(a[0][0],b[0][0]);
    d[0][0]=max(a[0][0],b[0][0]);
    
    //copied min in c array and max in d
    
    y=c[0][0];
   
    //for 0th row
    for(j=1;j<m;j++)
    {
        if(a[0][j]<b[0][j])
        {
            if(a[0][j]>y)
            {
                c[0][j]=a[0][j];
                d[0][j]=b[0][j];
                y=c[0][j];
            }
            else if(b[0][j]>y)
            {
                c[0][j]=b[0][j];
                d[0][j]=a[0][j];
                y=c[0][j];
            }
            else
            {
                flag=1;
                break;
            }
        }
        else if(b[0][j]<a[0][j])
        {
            if(b[0][j]>y)
            {
                c[0][j]=b[0][j];
                d[0][j]=a[0][j];
                y=b[0][j];
            }
            else if(a[0][j]>y)
            {
                c[0][j]=a[0][j];
                d[0][j]=b[0][j];
                y=c[0][j];
            }
            else
            {
                flag=1;
                break;
            }
        }
    }
    
    //for other rows

    k=0;

    for(i=1;i<n;i++)
    {
        y=c[0][k];
        
        for(j=0;j<m;j++)
        {
            
            if(a[i][j]<b[i][j])
            {
                if(a[i][j]>y)
                {
                    c[i][j]=a[i][j];
                    d[i][j]=b[i][j];
                    y=c[i][j];
                }
                else if(b[i][j]>y)
                {
                    c[i][j]=b[i][j];
                    d[i][j]=a[i][j];
                    y=c[i][j];
                }
                else
                {
                    flag=1;
                    break;
                }
            }
            else if(b[i][j]<a[i][j])
            {
                if(b[i][j]>y)
                {
                    c[i][j]=b[i][j];
                    d[i][j]=a[i][j];
                    y=b[i][j];
                }
                else if(a[i][j]>y)
                {
                    c[i][j]=a[i][j];
                    d[i][j]=b[i][j];
                    y=c[i][j];
                }
                else
                {
                    flag=1;
                    break;
                }
            }
            
        }
        k++;
    }
    /*for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cout<<c[i][j]<<"\t";
        }
        cout<<endl;
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cout<<c[i][j]<<"\t";
        }
        cout<<endl;
    }*/

    
    //to check if d matrix is increasing or not
    
    z=d[0][0];
    
    for(j=1;j<m;j++)
    {
        if(d[0][j]>z)
        {
            z=d[0][j];
        }
        else
        {
            flag=1;
            break;
        }
    }
        
    
    k=0;
        
    for(i=1;i<n;i++)
    {
        z=d[0][k];
        for(j=0;j<m;j++)
        {
            if(d[i][j]>z)
            {
                z=d[i][j];
            }
            else
            {
                break;
                flag=1;
            }
        }
        k++;
    }

    if(flag==1)
    {
        cout<<"Impossible";
    }
    else 
        cout<<"Possible";
   
    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details