11349  Symmetric Matrix
Moderator: Board moderators

 New poster
 Posts: 10
 Joined: Sun Sep 16, 2007 9:35 am
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.

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

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

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

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

 New poster
 Posts: 15
 Joined: Tue Sep 25, 2007 3:07 am
 Location: Astana, Kazakhstan
 Contact:
What is wrong with this code, I got WA?
Please give sample input with the correct output that make my program fail.
Code: Select all
thanx, luishhh and sclo! got AC
Last edited by armansuleimenov on Wed Nov 14, 2007 5:54 am, edited 3 times in total.

 New poster
 Posts: 15
 Joined: Tue Sep 25, 2007 3:07 am
 Location: Astana, Kazakhstan
 Contact:
Oh, I see: [2^32 ... 2^32] doesn't fit signed 32bit integer ([2^32...2^311]), I overlooked that. However I still get WA.
I changed this
to this
That is the only I change I need to do to use 64bit integers.
I changed this
Code: Select all
int m[110][110];
Code: Select all
long long m[110][110];
Just remove the word break from your code and you'll get AC.armansuleimenov wrote:Oh, I see: [2^32 ... 2^32] doesn't fit signed 32bit integer ([2^32...2^311]), I overlooked that. However I still get WA.
I changed this
to thisCode: Select all
int m[110][110];
That is the only I change I need to do to use 64bit integers.Code: Select all
long long m[110][110];
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.
Hello. I get WA with my code and i don't know why. Can you help me?
Thanks.
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[N1i][N1j])
sim = false;
}
}
cout << "Test #" << cas << ": ";
if(sim)
cout << "Symmetric." << endl;
else
cout << "Nonsymmetric." << endl;
}
}
wrong answer 11349
Someone please cheque my code ?
It's getting wrong answer
#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<<": Nonsymmetric."<<endl;
ctr++;
}
}
It's getting wrong answer
#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<<": Nonsymmetric."<<endl;
ctr++;
}
}
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
and thanx in advance
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
and thanx in advance
C++ Is The Best.