11349 - Symmetric Matrix

Moderator: Board moderators

rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Re: 11349 - Symmetric Matrix

amr saqr wrote:Actually, I'm having problems with understanding the problem description,
should i cut the matrix vertically or horizontally to make the comparison to check whether it's symmetric or not ????
sorry but I'm little confused here

No, you don't have to.
If the matrix is like:

Code: Select all

``````a b c d
e f g h
i j k l
m n o p``````
then you have to check;

Code: Select all

``All the values are non-negative and a==p && b==o && c==n && ..``
-----
Rio
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

Re: 11349 - Symmetric Matrix

Removed
Last edited by Obaida on Wed Jul 02, 2008 2:28 pm, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
Chirag Chheda
Learning poster
Posts: 74
Joined: Sat Jun 21, 2008 12:24 pm
Location: India

Why WA?????[:(]....its killing me

Code: Select all

``Code Acc!!!``
Last edited by Chirag Chheda on Fri Jun 27, 2008 8:23 am, edited 1 time in total.
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Contact:

Re: 11349 - Symmetric Matrix

Hi Chirag Chheda,
I think you should remove this line

Code: Select all

``system("pause");``
And another thing, you should initialize f=false.
Chirag Chheda
Learning poster
Posts: 74
Joined: Sat Jun 21, 2008 12:24 pm
Location: India

Re: 11349 - Symmetric Matrix

I made the changes suggested by you. But still i am getting WA.
And as far as system("pause") is concerned the judge dont give WA for that as in all my submissions
i send the code without removing it.

emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Contact:

Re: 11349 - Symmetric Matrix

Look at the definition -
Definition: Symmetric matrix is such a matrix that all elements of it are non-negative and symmetric with relation to the center of this matrix. Any other matrix is considered to be non-symmetric.
Please ensure all the things of this definition.
Chirag Chheda
Learning poster
Posts: 74
Joined: Sat Jun 21, 2008 12:24 pm
Location: India

Re: 11349 - Symmetric Matrix

Thank you sir..
finally i managed to get an ACC
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

Re: 11349 - Symmetric Matrix

But can someone explain why i am RTE.

>>my code is posted above.
try_try_try_try_&&&_try@try.com
This may be the address of success.
Chirag Chheda
Learning poster
Posts: 74
Joined: Sat Jun 21, 2008 12:24 pm
Location: India

Re: 11349 - Symmetric Matrix

Can u tell me y r u printing this line???

Code: Select all

``````printf("N = ");
``````
I think that's shud be in the input part and not the output part.

change it to:-

Code: Select all

``````scanf("%c%c",&c,&c);
``````
declare 'c' to be of char data type
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

Re: 11349 - Symmetric Matrix

Thank you very much. I always make such stupid mistake .
I never thought i should be inputed and getting RTE.

Again thank you for quick reply.
try_try_try_try_&&&_try@try.com
This may be the address of success.
A. M. Santos R.
New poster
Posts: 9
Joined: Sat Dec 01, 2007 1:42 am

Re: 11349 - Symmetric Matrix

I think the problem statement is unclear:
Elements of this matrix are Mij: {0 < i < n, 0 < j < n}.
It should be Mij: {1 <= i <= n, 1 <= j <= n}.
It would be easy.
sharath
New poster
Posts: 6
Joined: Tue Sep 16, 2008 9:21 pm

Re: 11349 - Symmetric Matrix

#include <stdio.h>

int main ()
{
int num_test, k, n, i, j, flag;
long long a[110][110];
char junk;

scanf ("%d", &num_test);
k = 0;

NEXT_CASE:
while (k++ < num_test)
{
fflush (stdin);
scanf ("%c %c %d", &junk, &junk, &n);
flag = 0;
for (i = 0;i < n; i ++)
{
for (j = 0;j < n;j ++)
{
scanf("%lld", &a[j]);
if (a[j] < 0)
{
printf ("Test #%d: Non-symmetric.\n", k);
flag = 1;
}
}
}

if (flag)
{
continue;
}

for (i = 0;i < n/2; i ++)
{
for (j = 0;j < n;j ++)
{
if (a[j] != a[n - i - 1][n - j - 1])
{
printf ("Test #%d: Non-symmetric.\n", k);
goto NEXT_CASE;
}
}
}

for (j = 0;j < n/2; j ++)
{
for (i = 0;i < n;i ++)
{
if (a[j] != a[n - i - 1][n - j - 1])
{
printf ("Test #%d: Non-symmetric.\n", k);
goto NEXT_CASE;
}
}
}
printf ("Test #%d: Symmetric.\n", k);
}
return 0;
}

Can someone please let me know what is wrong in the above code...I am getting RTE
kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Contact:

Re: 11349 - Symmetric Matrix

U need to read the input carefully.
suppose input is like

Code: Select all

``````1
N = 3
``````
first, u r taking 1 with

Code: Select all

``scanf ("%d", &num_test);``
that is okay.
then u r using

Code: Select all

``scanf ("%c %c %d", &junk, &junk, &n);``
Can u tell what will be the valu of junk and n here?
junk='\n'
junk='N'
n=garbage........

u can use this

Code: Select all

``scanf("\nN = %d",&n);``
or

Code: Select all

``scanf(" N = %d",&n);``
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
sharath
New poster
Posts: 6
Joined: Tue Sep 16, 2008 9:21 pm

Re: 11349 - Symmetric Matrix

@kbr_iut :
I have used fflush(stdin) before the statement scanf ("%c %c %d", &junk, &junk, &n); So the new line character would be flushed and n will have the value 3 for the input you have mentioned. Am I correct?
kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Contact:

Re: 11349 - Symmetric Matrix

I just copied ur code and run for sample input of this problem and ur code gives

Code: Select all

``````Test #1: Symmetric.
Test #2: Symmetric.
``````

and try to use code tag to post codes.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................