I am submitting the solution of Dfloor on spoj
http://www.spoj.pl/problems/DFLOOR/
,But is giving wrong answer every time  ,I have checked all the base
cases as well as many big test  cases,


According to me it is right ,,,, Is there anyone who has solved this problem




http://www.spoj.pl/problems/DFLOOR/
My code


#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stdio.h>

using namespace std;

char cmp(char s)
{
   if (s=='0')
       return '1';
   else if(s=='1')
       return '0';
}
/* Main code starts from here */
int main()
{
        vector<vector<char> > m(16,vector<char>(16));
        vector<int> arr1(226);
        vector<int> arr2(226);
        
        int i,j,x,y;
    while(1)
    {
        cin>>x>>y;
         if(x==0 &&y==0)
           return 0;


         for(i=0;i<y;i++)
         {
                for(j=0;j<x;j++)
                {
                     cin>>m[i][j];
                 }
         }

                    int k=0 ,flag=0;
        

         for(i=1;i<y;i++)
         {
                for(j=0;j<x;j++)
                {
                        if(m[i-1][j]=='0')
                        {
                                        m[i][j]=cmp(m[i][j]);
                                if((i-1)>=0)
                                        m[i-1][j]=cmp(m[i-1][j]);
                        
                                if((j+1)<=x)
                                        m[i][j+1]=cmp(m[i][j+1]);

                                if((i+1)<=y)
                                        m[i+1][j]=cmp(m[i+1][j]);
                                if((j-1)>=0)
                                        m[i][j-1]=cmp(m[i][j-1]);
                                
                                        k++;
                                arr1[k]=i+1;
                                arr2[k]=j+1;
                                        
                         }
                 }
         }
        
         for(i=1;i<y;i++)
         {
                for(j=0;j<x;j++)
                {
                    if(m[i][j]=='0')
                        flag=1;
                }
        }
        
        
          if(flag==1)
                 cout<<"-1"<<endl;
          else
          {
        
                                        
                cout<<k<<endl;
                 for(i=1;i<=k;i++)
                 {
                         cout<<arr2[i]<<" "<<arr1[i]<<endl;
                 }
          }
        
    }

return 0;
}








-- 
*Anil  Arya,
Computer Science *
*Motilal Nehru National Institute of Technology,Allahabad .
*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to