All about problems in Volume 112. If there is a thread about your problem, please use it. If not, create one with its number in the subject.
Moderator: Board moderators
pipo
New poster
Posts: 47 Joined: Tue May 11, 2004 6:43 pm
Location: Republic of Korea
Post
by pipo » Fri Jul 06, 2007 2:31 am
hi all...
I got WA
In my thought, this problem is easy... but I got WA
I don't know where is wrong...
Could you give me some sample inputs and outputs ??
thanks in advance...
mmonish
Experienced poster
Posts: 109 Joined: Sun Mar 11, 2007 2:55 pm
Location: SUST
Post
by mmonish » Fri Jul 06, 2007 3:39 am
I also think it's an easy problem.
Try this cases
Code: Select all
5
sdfg ?!@# dfdsfg.,./?><45344354)(*&^%^%% gfsddfgfds
abcdbfgc, ,cgfbdcba*(][
a
a,b.a
aaa!!!!aaa
My AC output
Code: Select all
Case #1:
No magic :(
Case #2:
4
Case #3:
1
Case #4:
No magic :(
Case #5:
No magic :(
Hope this helps.
Last edited by
mmonish on Sat Jul 07, 2007 3:34 am, edited 1 time in total.
pipo
New poster
Posts: 47 Joined: Tue May 11, 2004 6:43 pm
Location: Republic of Korea
Post
by pipo » Fri Jul 06, 2007 3:53 am
hm... mmonish...
Is the 2 case right ??
The sentence of the second way in problem statement is not equal to original sentence.
mmonish
Experienced poster
Posts: 109 Joined: Sun Mar 11, 2007 2:55 pm
Location: SUST
Post
by mmonish » Sat Jul 07, 2007 3:37 am
Thanks pipo u r right. Probably there is no test case like this in the judge data.
Now i edit my post.
chinmoy kanti dhar
New poster
Posts: 19 Joined: Fri Jun 22, 2007 6:17 pm
Location: bangladesh
Post
by chinmoy kanti dhar » Sat Jul 14, 2007 11:22 pm
this program gives run time error(signal 11).help me plz
code:
cut
tanvir
New poster
Posts: 22 Joined: Wed Aug 31, 2005 12:09 pm
Post
by tanvir » Sat Jul 14, 2007 11:51 pm
I think ur array(for array d) index is bouncing for the line:
check it...
tanvir
chinmoy kanti dhar
New poster
Posts: 19 Joined: Fri Jun 22, 2007 6:17 pm
Location: bangladesh
Post
by chinmoy kanti dhar » Sun Jul 15, 2007 12:04 am
thanks tanvir for ur reply.but i dont understanad why it will cause pb.my program's pb is invalid memory reference.it is necessary to increase array size?
tanvir
New poster
Posts: 22 Joined: Wed Aug 31, 2005 12:09 pm
Post
by tanvir » Sun Jul 15, 2007 12:49 am
look a bit more carefully?
what was the reason to write this line:
why u r comparing n with 6??????
hope it helps
tanvir
ferng1021
New poster
Posts: 9 Joined: Thu Feb 23, 2006 5:09 pm
Location: Taipei, Taiwan
Post
by ferng1021 » Wed Aug 22, 2007 11:21 am
I passed sample I/O and the above test data, but still got WA...
can any body help me?
thank you!
Code: Select all
#include<stdio.h>
#include<string.h>
int csN, csk, L, K;
char S[10002];
inline bool Equal(char a, char b, char c, char d)
{
return a == b && a == c && a == d;
}
int main()
{
int i, j, t;
char ok;
scanf("%d\n", &csN);
for(csk = 1; csk <= csN; ++csk)
{
fgets(S, 10001, stdin);
L = strlen(S);
for(i = t = 0; i < L; ++i)
{
if(S[i] < 'a' || S[i] > 'z') ++t;
else S[i-t] = S[i];
}
L -= t;
S[L] = '\0';
for(K = 1; K*K < L; ++K) ;
if(K*K != L) ok = 0;
else
{
for(i = 0; i < K; ++i)
{
for(j = 0; j < K; ++j)
if(!Equal(S[i*K+j], S[(K-i-1)*K+(K-j-1)], S[j*K+i], S[(K-j-1)*K+(K-i-1)])) break;
if(j < K) break;
}
ok = (i==K);
}
if(ok) printf("Case #%d:\n%d\n", csk, K);
else printf("Case #%d:\nNo magic :(\n", csk);
}
}
rhsumon
New poster
Posts: 48 Joined: Wed Aug 23, 2006 12:29 pm
Location: Dhaka
Post
by rhsumon » Sat Sep 08, 2007 5:27 pm
Hi, I have tried it wth a simple thinking it is:
1. I count the letters.
2. Chack this is a sqr number or not
3. than check the str palindrom or not
Oh a silly mistake AC now!!!!!!!!!!!!
Fuad Hassan EWU
New poster
Posts: 38 Joined: Tue Jul 17, 2007 3:21 pm
Location: East West University
Post
by Fuad Hassan EWU » Tue Sep 18, 2007 3:56 pm
why WA? is mmonish's last 2 output is right?how?
Last edited by
Fuad Hassan EWU on Fri Sep 21, 2007 8:00 pm, edited 2 times in total.
Eagle er moto daana meley urbo
Jan
Guru
Posts: 1334 Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:
Post
by Jan » Wed Sep 19, 2007 7:04 am
Use str[1001][1001]. And check the case below.
Input:
Code: Select all
1
abcdef bptuse cqzxrd drxzqc esutpb fedcba
Output:
Hope it helps.
Fuad Hassan EWU
New poster
Posts: 38 Joined: Tue Jul 17, 2007 3:21 pm
Location: East West University
Post
by Fuad Hassan EWU » Wed Sep 19, 2007 7:16 pm
jan vai my code is giving its output 6. if i arrange the input it has the figure--
Code: Select all
abcdef
bptuse
cqzxrd
drxzqc
esutpb
fedcba
is not this magic sqare palindrome? if not then why? plz explain.
Eagle er moto daana meley urbo
Jan
Guru
Posts: 1334 Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:
Post
by Jan » Thu Sep 20, 2007 1:06 am
Read the description again...
A magic square palindrome is a sentence whose characters can be divided in a K x K square table with the property that the original sentence can be read from the table in four different ways:
Start from the (1,1) cell, move right until the end of the line and than proceed to the next line.
Start from the (1,1) cell, move down until the end of the column and then proceed to the next column.
Start from the (K,K) cell, move left until the beginning of the line and then proceed to the previous line.
Start from the (K,K) cell, move up until the beginning of the column and then proceed to the previous column.
If we read them from the square we get...
Code: Select all
1. abcdefbptusecqzxrddrxzqcesutpbfedcba
2. abcdefbpqrsectzxudduxztcesrqpbfedcba
3. abcdefbptusecqzxrddrxzqcesutpbfedcba
4. abcdefbpqrsectzxudduxztcesrqpbfedcba
And you can see that all of them are not equal. Hope it helps.