Page 1 of 3

11349 - Symmetric Matrix

Posted: Mon Nov 12, 2007 11:39 am
by Hojjat jafary
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.

Posted: Mon Nov 12, 2007 12:09 pm
by emotional blind
there is also a center of the matrix when n is even.

Posted: Mon Nov 12, 2007 3:20 pm
by shakil
What it mean????
symmetric with relation to the center of this matrix.

Posted: Mon Nov 12, 2007 4:37 pm
by Hojjat jafary
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

Posted: Mon Nov 12, 2007 4:49 pm
by emotional blind
Second one, I think that should be enough information now.. :D

Posted: Mon Nov 12, 2007 8:52 pm
by Hojjat jafary
thanks for your replay i got ac.

Posted: Tue Nov 13, 2007 9:49 pm
by armansuleimenov
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.

Posted: Tue Nov 13, 2007 9:52 pm
by luishhh
use long longs

Posted: Wed Nov 14, 2007 5:08 am
by armansuleimenov
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.

Posted: Wed Nov 14, 2007 5:26 am
by sclo
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)

PS. Please remove your code.

Posted: Fri Nov 16, 2007 12:01 am
by damarro
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.

Posted: Fri Nov 16, 2007 12:40 am
by Lomir
Read the problem statement once again.

wrong answer 11349

Posted: Wed Nov 21, 2007 10:20 am
by mukit
Someone please cheque my code ?
It's getting wrong answer :evil:

#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[j];
}
}*/
x=1;
y=di;
for(i=1,j=di;i<=di/2,j>=di/2;i++,j--)
{
if(m[x]==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[j];
}
}*/
x=1;
y=di;
for(i=1,j=di;i<=di,j>0;i++,j--)
{
if(m[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[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++;
}
}

Posted: Wed Nov 21, 2007 10:41 am
by rio
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

Re: 11349 - Symmetric Matrix

Posted: Thu May 08, 2008 8:21 am
by amr saqr
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