Page 4 of 4

Re: 11221 - Magic square palindromes

Posted: Sat Aug 09, 2014 6:14 am
by Shahidul.CSE
Thanks lbv! Now Got AC. :D :D

Re: 11221 - Magic square palindromes.

Posted: Tue Nov 18, 2014 5:06 pm
by gfv
It gives me WA even though I passed all test cases:

Code: Select all

Removed due to AC
EDIT: Nvm, i was forgeting the almost invisible ":" at the end of the "Case n#:" line

Re: 11221 - Magic square palindromes

Posted: Tue Nov 18, 2014 6:01 pm
by gfv
gdisastery wrote:Input:

Code: Select all

2
:) ~ :D ~~~~ :))))))) :D :D :D
:P :P :P :P
AC Output:

Code: Select all

Case #1:
2
Case #2:
2
I ran it on toolkit and it gave me the same output my code did:

Code: Select all

Case #1:
0
Case #2:
0
Indeed, it doesn't really matter once judge ignores capital letters (there won't be capital inputs, it's in the specification).

Re: 11221 - Magic square palindromes.

Posted: Tue Nov 18, 2014 11:18 pm
by brianfry713
Always print a newline char at the end of the last line.

Re: 11221 - Magic square palindromes.

Posted: Wed Nov 19, 2014 1:04 am
by gfv
Did it, still WA. Already tried with and without the final \n;

Re: 11221 - Magic square palindromes.

Posted: Tue Feb 03, 2015 4:32 pm
by Shafayat
Can anyone tell me why I got WA?

Code: Select all

Removed after accepted

Re: 11221 - Magic square palindromes.

Posted: Thu Feb 05, 2015 1:27 am
by brianfry713
Describe or comment your code. What are o, q, and r?

Re: 11221 - Magic square palindromes.

Posted: Thu Feb 05, 2015 7:36 pm
by Shafayat
As gets() function can not get input after using scanf("%d"...., so I input number of test case in a string p[10]. Then convert in into integer. After that I use gets(m) to input characters of the square. From m, I separate all alphabets into n. Then check whether its length is a square of a integer number or not. If it is not, then display "No magic". Else, I copy alphabets of the square vertically in string o. It means starts from (1,1) go down till end of the column.Then starts from next column and so on. After that reverse the string n to the string q. r is used here to store again vertical alphabets, means starts from the ending square and go up till starting square of the column. Then go to the ending of previous square and again go up and so on. Then compare n,o,q and r. If these are same display square. Else display No magic.

Re: 11221 - Magic square palindromes.

Posted: Thu Feb 05, 2015 9:18 pm
by brianfry713
The length of a line can be up to 10,000 chars long.
Increase the size of m, n, o, q, and r to at least 10,001.

Re: 11221 - Magic square palindromes.

Posted: Thu Feb 05, 2015 9:22 pm
by Shafayat
Thanks a lot. Got accepted

Re: 11221 - Magic square palindromes.

Posted: Tue May 12, 2015 10:43 pm
by coder.tanvir

Code: Select all

#include <bits/stdc++.h>
int main()
{
    char cas[10];
    int ca , x=0;
    gets(cas);
    ca=atoi(cas);
    while(ca--)
    {
        char line[10010];
        char final_[10010];
        char final_1[10010];
        char final_2[10010];
        char final_3[10010];
        gets(line);
        int len = strlen(line) ;
        int j=0;
        
        for(int i=0; i< len; i++)
            if(line[i]>='a' && line[i]<='z')
                final_[j++]=line[i];
                
        final_[j]='\0';

        int sp=sqrt(j);
        if(sp*sp!=j) printf("Case #%d:\nNo magic :(\n",++x);
        else{
            int pos=0;
            
            for(int i=0 ; i< sp ; i++)
                for(int j=0 ; j<sp ; j++)
                    final_1[pos++]=final_[j*sp+i];

            final_1[pos]='\0';
            pos=0;

            for(int i=sp-1 ; i>=0 ; i--)
                for(int j=sp-1 ; j>=0 ; j--)
                    final_2[pos++]=final_[j*sp+i];

            final_2[pos]='\0';
            pos=0;

            for(int i=sp-1 ; i>=0 ; i--)
                for(int j=sp-1 ; j>=0 ; j--)
                    final_3[pos++]=final_[i*sp+j];

            final_3[pos]='\0';
            if(strcmp(final_,final_1)==0 && strcmp(final_,final_2)==0 && strcmp(final_,final_3)==0 ) printf("Case #%d\n%d\n",++x,sp);
            else printf("Case #%d:\nNo magic :(\n",++x);
        }
    }
    return 0;
}

getting WA

Re: 11221 - Magic square palindromes.

Posted: Sat Oct 03, 2015 1:57 pm
by KiBurst
It was already said once before but I am going to restate it as it caused me over an hour of grief.
length(L) < 10.000 is incorrect, it is actually length(L) <= 10.000
My approach involved initially checking if the input String was an appropriate size in order to fit into a square and ruling out the possibility of a 100x100 square was giving me WA.

Re: 11221 - Magic square palindromes.

Posted: Sat Jan 21, 2017 10:44 am
by kaiser harlequin

Code: Select all

#include <iostream>
#include<math.h>
#include<stdio.h>
using namespace std;

int main() {

string w;

int quit[999],lo,al[999];
//getline(cin,w);
cin>>lo;

cin.ignore(256, '\n');


for(int y=0;y<lo;y++)
{

int u=0,x=0,qw;
float r;
char f[1000][1000];
string str,we="";
getline(cin, str);

//cout<<str;
for(long long int i=0;i<str.length();i++)
{
int b=str[i];

if(b>=97 && b<=122)
we=we+str[i];

}
//cout<<we<<endl;
r=sqrt(we.length());
qw=(int)r;
//cout<<qw;
if(qw==r)
{
for(long long int ty=0;ty<qw;ty++)
{
for(long long int qe=0;qe<qw;qe++)
{
f[ty][qe]=we[x];
++x;
}
}
for(long long int hy=0;hy<qw;hy++)
{
for(long long int rq=0;rq<qw;rq++)
{

//cout<<f[hy][rq];
if(f[hy][rq]!=f[rq][hy])
++u;
}
//cout<<endl;
}

}
else u=1;
//cout<<u;

quit[y]=u;
al[y]=qw;
}
for(int p=0;p<lo;p++)
{
if(quit[p]==0)
{


cout<<"Case #"<<p+1<<":"<<endl;
if(p!=(lo-1))
cout<<al[p]<<endl;
else cout<<al[p];

}


else
{cout<<"Case #"<<p+1<<":"<<endl<<"No magic :(";
if(p!=(lo-1))
cout<<endl;

}
}




}






[quote]why wrong answer despite sattisfying most test cases.[/quote]

Re: 11221 - Magic square palindromes.

Posted: Sun Mar 12, 2017 2:57 pm
by lighted
Don't double post. Input

Code: Select all

1
sator azepo tenet opera rotas
Output

Code: Select all

Case #1:
No magic :(