ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1124. Mosaic

WA =( show me my mistakes, please!
Posted by CExFX 21 Aug 2007 19:27
I have WA and I don't know why.
All tests I've done gave me right answers.
Somebody, please help me, show me my mistakes!!!

Text of program(С++):
#include <iostream.h>
void main()
{
     short M,N;
     int j;
     cout<<"Enter amounts of colors and pieces\n";
     cin>>M>>N;
     cout<<"\nEnter all pieces\n";
     short a[500][50];
     for (int i=0; i<M; i++)
          for ( j=0; j<N; j++)
               cin>>a[i][j];
    short t,z,u=0,kolvo=0,p=0,q=0;

do
{
          for ( i=0; i<M; i++)
          for ( j=0; j<N; j++)
          if(a[i][j]!=(i+1))
          {
               p=j;
               q=i;

               if(u==0)
               t=a[i][j];
               else
               {
               z=a[i][j];
               a[i][j]=t;
               t=z;
               }
               kolvo++;



               for (int k=0; k<N; k++)
                    if (a[t-1][k]!=t)
                    {
                    z=a[t-1][k];
                    a[t-1][k]=t;
                    t=z;
                    u=1;
                    kolvo++;

                    }

                    if (N==1)i=t-2;
                    else
                         i=t-1;
                    j=0;

          }

}while((i<M)&&(j<N));
if(u==1) kolvo--;
cout<<"\nAnswer is="<<kolvo;


}
Re: WA =( show me my mistakes, please!
Posted by DixonD (Lviv NU) 21 Aug 2007 21:38
You haven't to write some code like
cout<<"Enter amounts of colors and pieces\n";

and read FAQ before using Online Judge
Still WA
Posted by CExFX 21 Aug 2007 22:36
Thank you, but sill WA on 6th test.
=(
Re: Still WA
Posted by CHIDEMYAN SERGEY 22 Aug 2007 02:31
Try to change short into int>Maybe then you'll get AC.
Re: Still WA
Posted by CExFX 22 Aug 2007 03:10
I've already tried to do as you say,but still WA.