## 11349 - Symmetric Matrix

Moderator: Board moderators

### 11349 - Symmetric Matrix

the problem statement is not clear to me because i don't know what should i do when n the dimension of the matrix is even like 4.
Hojjat jafary
New poster

Posts: 10
Joined: Sun Sep 16, 2007 9:35 am

there is also a center of the matrix when n is even.

emotional blind
A great helper

Posts: 383
Joined: Mon Oct 18, 2004 8:25 am

What it mean????
symmetric with relation to the center of this matrix.
SHAKIL
shakil
Learning poster

Posts: 74
Joined: Sat Jul 15, 2006 6:28 am

which of these matrix are Symmetric?
1 6 7 1
7 2 3 1
1 3 2 7
1 5 4 1

or
1 4 5 1
7 2 3 1
1 3 2 7
1 5 4 1
All Professionals was once an amateur.
Hojjat jafary
New poster

Posts: 10
Joined: Sun Sep 16, 2007 9:35 am

Second one, I think that should be enough information now..

emotional blind
A great helper

Posts: 383
Joined: Mon Oct 18, 2004 8:25 am

thanks for your replay i got ac.
All Professionals was once an amateur.
Hojjat jafary
New poster

Posts: 10
Joined: Sun Sep 16, 2007 9:35 am

What is wrong with this code, I got WA?

Code: Select all
`thanx, luishhh and sclo! got AC`

Please give sample input with the correct output that make my program fail.
Last edited by armansuleimenov on Wed Nov 14, 2007 5:54 am, edited 3 times in total.
armansuleimenov
New poster

Posts: 15
Joined: Tue Sep 25, 2007 3:07 am
Location: Astana, Kazakhstan

use long longs
"From lost to the river" --> Spanish quote
luishhh
New poster

Posts: 26
Joined: Mon Oct 25, 2004 8:11 pm
Location: Spain

Oh, I see: [-2^32 ... 2^32] doesn't fit signed 32-bit integer ([-2^32...2^31-1]), I overlooked that. However I still get WA.

I changed this

Code: Select all
`int m[110][110]; `

to this

Code: Select all
`long long m[110][110]; `

That is the only I change I need to do to use 64-bit integers.
armansuleimenov
New poster

Posts: 15
Joined: Tue Sep 25, 2007 3:07 am
Location: Astana, Kazakhstan

armansuleimenov wrote:Oh, I see: [-2^32 ... 2^32] doesn't fit signed 32-bit integer ([-2^32...2^31-1]), I overlooked that. However I still get WA.

I changed this

Code: Select all
`int m[110][110]; `

to this

Code: Select all
`long long m[110][110]; `

That is the only I change I need to do to use 64-bit integers.

Just remove the word break from your code and you'll get AC.
As a rule, avoid use of the keyword break when reading input. (The only exception is to detect terminal character or delimiters)

sclo
Guru

Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm

Hello. I get WA with my code and i don't know why. Can you help me?
Code: Select all
`#include <iostream>using namespace std;int main() {   long long M[110][110];   int T;   cin >> T;   for(int cas = 1; cas <= T; cas++) {      char a, b;      int N;      cin >> a >> b >> N;            if(N <= 0)         continue;            for(int i = 0; i < N; i++)         for(int j = 0; j < N; j++)            cin >> M[i][j];            bool sim = true;      for(int i = 0; i < N; i++) {         for(int j = 0; j < N; j++) {            if(M[i][j] != M[N-1-i][N-1-j])               sim = false;         }      }            cout << "Test #" << cas << ": ";      if(sim)         cout << "Symmetric." << endl;      else         cout << "Non-symmetric." << endl;   }}`

Thanks.
damarro
New poster

Posts: 1
Joined: Thu Nov 15, 2007 11:57 pm

Read the problem statement once again.
Lomir
New poster

Posts: 19
Joined: Mon Sep 17, 2007 10:05 pm

Someone please cheque my code ?

#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 102
long long m[MAX][MAX];
int di;
int res=89;
int res2=90;
int func(int di)
{
int x=1;
int y=1;
int i,j;
{
/*for(i=1;i<=di;i++)
{
for(j=1;j<=di;j++)
{
cin>>m[i][j];
}
}*/
x=1;
y=di;
for(i=1,j=di;i<=di/2,j>=di/2;i++,j--)
{
if(m[x][i]==m[y][j])res=1;
else res=0;
}
return res;
}
}
int func2(int di)
{
int x=1;
int y=1;
int i,j;
{
/*for(i=1;i<=di;i++)
{
for(j=1;j<=di;j++)
{
cin>>m[i][j];
}
}*/
x=1;
y=di;
for(i=1,j=di;i<=di,j>0;i++,j--)
{
if(m[i][x]==m[j][y])res2=1;
else res2=0;
}
return res2;
}
}
int main()
{
int test;
int xm;
int ctr=1;
int i,j;
char c,c1;
cin>>test;
for(xm=0;xm<test;xm++)
{
cin>>c>>c1>>di;
for(i=1;i<=di;i++)
{
for(j=1;j<=di;j++)
{
cin>>m[i][j];
}
}
if(di%2==0)di/=2;
else di=(di/2)+1;
func(di);
func2(di);
if(res==1 && res2==1) cout<<"Test #"<<ctr<<": Symmetric."<<endl;
else cout<<"Test #"<<ctr<<": Non-symmetric."<<endl;
ctr++;
}
}
mukit
New poster

Posts: 48
Joined: Wed Nov 21, 2007 10:09 am

Your code doesn't even pass the sample input..
Try to pass the sample input first.

And when you post your code, use code tag. It will be easier to see.
-----
Rio

rio
A great helper

Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

### Re: 11349 - Symmetric Matrix

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

C++ Is The Best.
amr saqr
New poster

Posts: 29
Joined: Tue Mar 11, 2008 6:35 pm

Next