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

Hojjat jafary
New poster
Posts: 10
Joined: Sun Sep 16, 2007 9:35 am

11349 - Symmetric Matrix

Post by Hojjat jafary » Mon Nov 12, 2007 11:39 am

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.

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

Post by emotional blind » Mon Nov 12, 2007 12:09 pm

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

shakil
Learning poster
Posts: 74
Joined: Sat Jul 15, 2006 6:28 am
Location: CUET , bangladesh
Contact:

Post by shakil » Mon Nov 12, 2007 3:20 pm

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

Hojjat jafary
New poster
Posts: 10
Joined: Sun Sep 16, 2007 9:35 am

Post by Hojjat jafary » Mon Nov 12, 2007 4:37 pm

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.

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

Post by emotional blind » Mon Nov 12, 2007 4:49 pm

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

Hojjat jafary
New poster
Posts: 10
Joined: Sun Sep 16, 2007 9:35 am

Post by Hojjat jafary » Mon Nov 12, 2007 8:52 pm

thanks for your replay i got ac.
All Professionals was once an amateur.

armansuleimenov
New poster
Posts: 15
Joined: Tue Sep 25, 2007 3:07 am
Location: Astana, Kazakhstan
Contact:

Post by armansuleimenov » Tue Nov 13, 2007 9:49 pm

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.

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

Post by luishhh » Tue Nov 13, 2007 9:52 pm

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

armansuleimenov
New poster
Posts: 15
Joined: Tue Sep 25, 2007 3:07 am
Location: Astana, Kazakhstan
Contact:

Post by armansuleimenov » Wed Nov 14, 2007 5:08 am

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.

sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo » Wed Nov 14, 2007 5:26 am

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.

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

Post by damarro » Fri Nov 16, 2007 12:01 am

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.

Lomir
New poster
Posts: 19
Joined: Mon Sep 17, 2007 10:05 pm
Contact:

Post by Lomir » Fri Nov 16, 2007 12:40 am

Read the problem statement once again.

mukit
New poster
Posts: 48
Joined: Wed Nov 21, 2007 10:09 am
Location: Dhaka , Bangladesh
Contact:

wrong answer 11349

Post by mukit » Wed Nov 21, 2007 10:20 am

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++;
}
}

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

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

amr saqr
New poster
Posts: 29
Joined: Tue Mar 11, 2008 6:35 pm

Re: 11349 - Symmetric Matrix

Post by amr saqr » Thu May 08, 2008 8:21 am

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
C++ Is The Best.

Post Reply

Return to “Volume 113 (11300-11399)”