11349 - Symmetric Matrix

All about problems in Volume 113. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

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

Re: 11349 - Symmetric Matrix

Post by rio » Mon Jun 02, 2008 11:01 am

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 :oops:

and thanx in advance
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
Location: (BUBT) Dhaka,Bagladesh.

Re: 11349 - Symmetric Matrix

Post by Obaida » Mon Jun 02, 2008 12:31 pm

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

Post by Chirag Chheda » Sat Jun 21, 2008 2:55 pm

Code: Select all

Code Acc!!!
Last edited by Chirag Chheda on Fri Jun 27, 2008 8:23 am, edited 1 time in total.

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

Re: 11349 - Symmetric Matrix

Post by emotional blind » Sun Jun 22, 2008 8:52 am

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

Post by Chirag Chheda » Sun Jun 22, 2008 10:31 am

Thank you sir for replying.
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.

Waiting for your reply

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

Re: 11349 - Symmetric Matrix

Post by emotional blind » Mon Jun 23, 2008 5:42 am

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

Post by Chirag Chheda » Mon Jun 23, 2008 7:41 am

Thank you sir..
finally i managed to get an ACC

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 11349 - Symmetric Matrix

Post by Obaida » Wed Jul 02, 2008 12:51 pm

But can someone explain why i am RTE.

>>my code is posted above. :oops:
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

Post by Chirag Chheda » Wed Jul 02, 2008 2:16 pm

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
Location: (BUBT) Dhaka,Bagladesh.

Re: 11349 - Symmetric Matrix

Post by Obaida » Wed Jul 02, 2008 2:37 pm

Thank you very much. I always make such stupid mistake :oops: .
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

Post by A. M. Santos R. » Sun Jul 20, 2008 6:29 pm

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

Post by sharath » Tue Jun 30, 2009 12:56 pm

#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 :oops:

User avatar
kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH
Contact:

Re: 11349 - Symmetric Matrix

Post by kbr_iut » Fri Jul 03, 2009 1:18 am

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

Post by sharath » Tue Jul 07, 2009 11:05 am

@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?

User avatar
kbr_iut
Experienced poster
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH
Contact:

Re: 11349 - Symmetric Matrix

Post by kbr_iut » Tue Jul 07, 2009 5:58 pm

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...............................

Post Reply

Return to “Volume 113 (11300-11399)”