Page 12 of 14
401-Palindromes Why getting WA
Posted: Sun Sep 08, 2013 2:56 am
by cse.komol
Please someone check this, why i am getting WA
Re: 401-Palindromes Why getting WA
Posted: Mon Sep 09, 2013 10:51 pm
by brianfry713
Try running your code on the sample input.
Re: 401-Palindromes Why getting WA
Posted: Wed Sep 18, 2013 1:23 am
by Salsabil
i've tried all the test cases here, still i'm getting wa.. please help.
here is my code:
http://paste.ubuntu.com/6121263/
Re: 401-Palindromes Why getting WA
Posted: Thu Sep 19, 2013 1:12 am
by brianfry713
AE -- is not a palindrome.
Re: 401-Palindromes Why getting WA
Posted: Sat Feb 01, 2014 12:32 am
by beboo
i need help with the code i dont know why i get WA
#include <iostream>
#include <stdlib.h>
#include <sstream>
#include <string>
#include <string.h>
#include<algorithm>
#include <math.h>
#include <iomanip>
#include<stdio.h>
#define min(x,y) ((x)<(y)? x:y)
using namespace std;
int main()
{
//freopen("beboo.txt","r",stdin);
string S;
string L="AEHIJLMOSTUVWXYZ12358";
bool mir=false;
bool pal=false;
bool first =false;
int count=0; int count2=0;
int check=0;
while(cin>>S)
{
check=0;
pal=false;
mir=false;
int y=S.length();
int x=((y)/2);
int a=y-1; int b=0;
//cout<<S[0]<<" "<<S[S.length()-1]<<endl;
if(first==true)
// {cout<<endl;}
first=true;
count =0; count2=0;
for(int i=0;i<x;i++)
{
if (S[a]==S)
{count++;
count2++;
if(S[a]=='B'||S[a]=='C'||S[a]=='D'
||S[a]=='F'||S[a]=='G'||S[a]=='K'
||S[a]=='P'||S[a]=='Q'||S[a]=='R'
||S[a]=='4'||S[a]=='0'
||S[a]=='6'||S[a]=='7'||S[a]=='9'||S[a]=='E'||S[a]=='3'
||S[a]=='S'||S[a]=='2'
||S[a]=='Z'||S[a]=='5')
{mir=false;
count2--;}
for(int i=0;i<L.length();i++)
{if(S[a]!=L)
{check++;}
}
if(check==L.length())
{count2--;}
}
else
{
pal=false;
if(S[a]=='B'||S[a]=='C'||S[a]=='D'||S=='B'||S=='C'||S=='D'
||S[a]=='F'||S[a]=='G'||S[a]=='K'||S=='F'||S=='G'||S=='K'
||S[a]=='P'||S[a]=='Q'||S[a]=='R'||S=='P'||S=='Q'||S=='R'
||S[a]=='4'||S[b]=='4'||S[a]=='0'||S[b]=='0'
||S[a]=='6'||S[a]=='7'||S[a]=='9'||S[b]=='6'||S[b]=='7'||S[b]=='9')
{
mir=false;
break;
}
else if(S[a]=='E'&&S[b]=='3'||S[a]=='3'&&S[b]=='E'
||S[a]=='S'&&S[b]=='2'||S[a]=='2'&&S[b]=='S'
||S[a]=='Z'&&S[b]=='5'||S[a]=='5'&&S[b]=='Z'
)
{count2++;}
}
a--;
b++;
}
if(count==x)
{pal=true;}
if(count2==x)
{mir=true;}
if(y%2!=0)
{
int z=(y/2);
if(S[z]=='B'||S[z]=='C'||S[z]=='D'
||S[z]=='F'||S[z]=='G'||S[z]=='K'
||S[z]=='P'||S[z]=='Q'||S[z]=='R'
||S[z]=='4'||S[z]=='0'
||S[z]=='6'||S[z]=='7'||S[z]=='9')
{mir=false;}
}
if(y==1)
{
a=0;
if(S[a]=='B'||S[a]=='C'||S[a]=='D'
||S[a]=='F'||S[a]=='G'||S[a]=='K'
||S[a]=='P'||S[a]=='Q'||S[a]=='R'
||S[a]=='4'||S[a]=='0'
||S[a]=='6'||S[a]=='7'||S[a]=='9'||S[a]=='E'||S[a]=='3'
||S[a]=='S'||S[a]=='2'
||S[a]=='Z'||S[a]=='5')
{mir=false;}
}
if(pal==false&&mir==false)
{cout<<S<<" -- is not a palindrome.";}
else if(pal==false&&mir==true)
{cout<<S<<" -- is a mirrored string.";}
else if(pal==true&&mir==false)
{cout<<S<<" -- is a regular palindrome.";}
else
{cout<<S<<" -- is a mirrored palindrome.";}
cout<<endl;
cout<<endl;
}
return 0;
}//` ''
Re: 401- Palindromes
Posted: Sat Feb 01, 2014 1:16 am
by beboo
i need help with the code , plzzz x(
#include <iostream>
#include <stdlib.h>
#include <sstream>
#include <string>
#include <string.h>
#include<algorithm>
#include <math.h>
#include <iomanip>
#include<stdio.h>
#define min(x,y) ((x)<(y)? x:y)
using namespace std;
int main()
{
//freopen("beboo.txt","r",stdin);
string S;
string L="AEHIJLMOSTUVWXYZ12358";
bool mir=false;
bool pal=false;
bool first =false;
int count=0; int count2=0;
int check=0;
while(cin>>S)
{
check=0;
pal=false;
mir=false;
int y=S.length();
int x=((y)/2);
int a=y-1; int b=0;
//cout<<S[0]<<" "<<S[S.length()-1]<<endl;
if(first==true)
// {cout<<endl;}
first=true;
count =0; count2=0;
for(int i=0;i<x;i++)
{
if (S[a]==S)
{count++;
count2++;
if(S[a]=='B'||S[a]=='C'||S[a]=='D'
||S[a]=='F'||S[a]=='G'||S[a]=='K'
||S[a]=='P'||S[a]=='Q'||S[a]=='R'
||S[a]=='4'||S[a]=='0'
||S[a]=='6'||S[a]=='7'||S[a]=='9'||S[a]=='E'||S[a]=='3'
||S[a]=='S'||S[a]=='2'
||S[a]=='Z'||S[a]=='5'||S[a]=='L'||S[a]=='J')
{mir=false;
count2--;}
for(int i=0;i<L.length();i++)
{if(S[a]!=L)
{check++;}
}
if(check==L.length())
{count2--;}
}
else
{
pal=false;
if(S[a]=='B'||S[a]=='C'||S[a]=='D'||S=='B'||S=='C'||S=='D'
||S[a]=='F'||S[a]=='G'||S[a]=='K'||S=='F'||S=='G'||S=='K'
||S[a]=='P'||S[a]=='Q'||S[a]=='R'||S=='P'||S=='Q'||S=='R'
||S[a]=='4'||S[b]=='4'||S[a]=='0'||S[b]=='0'
||S[a]=='6'||S[a]=='7'||S[a]=='9'||S[b]=='6'||S[b]=='7'||S[b]=='9')
{
mir=false;
break;
}
else if(S[a]=='E'&&S[b]=='3'||S[a]=='3'&&S[b]=='E'
||S[a]=='S'&&S[b]=='2'||S[a]=='2'&&S[b]=='S'
||S[a]=='Z'&&S[b]=='5'||S[a]=='5'&&S[b]=='Z'
||S[a]=='J'&&S[b]=='L'||S[a]=='L'&&S[b]=='J'
)
{count2++;}
}
a--;
b++;
}
if(count==x)
{pal=true;}
if(count2==x)
{mir=true;}
if(y%2!=0)
{
int z=(y/2);
if(S[z]=='B'||S[z]=='C'||S[z]=='D'
||S[z]=='F'||S[z]=='G'||S[z]=='K'
||S[z]=='P'||S[z]=='Q'||S[z]=='R'
||S[z]=='4'||S[z]=='0'
||S[z]=='6'||S[z]=='7'||S[z]=='9')
{mir=false;}
}
if(y==1)
{
a=0;
if(S[a]=='B'||S[a]=='C'||S[a]=='D'
||S[a]=='F'||S[a]=='G'||S[a]=='K'
||S[a]=='P'||S[a]=='Q'||S[a]=='R'
||S[a]=='4'||S[a]=='0'
||S[a]=='6'||S[a]=='7'||S[a]=='9'||S[a]=='E'||S[a]=='3'
||S[a]=='S'||S[a]=='2'
||S[a]=='Z'||S[a]=='5'||S[a]=='J'||S[a]=='L')
{mir=false;}
}
if(pal==false&&mir==false)
{cout<<S<<" -- is not a palindrome.";}
else if(pal==false&&mir==true)
{cout<<S<<" -- is a mirrored string.";}
else if(pal==true&&mir==false)
{cout<<S<<" -- is a regular palindrome.";}
else
{cout<<S<<" -- is a mirrored palindrome.";}
cout<<endl;
cout<<endl;
}
return 0;
}//` ''
Re: 401-Palindromes Why getting WA
Posted: Mon Feb 03, 2014 9:51 pm
by brianfry713
Don't double post.
Re: 401- Palindromes
Posted: Mon Feb 03, 2014 10:09 pm
by brianfry713
A3A -- is a regular palindrome.
why wa in uva-401??
Posted: Mon May 26, 2014 7:14 pm
by setu basak
Code: Select all
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
using namespace std;
bool regular(string a)
{
int len = a.length();
bool flag = true;
for (int i = 0; i < len / 2; i++)
{
if (a.at(i) != a.at(len - i - 1))
{
flag = false;
break;
}
}
return flag;
}
bool mirror(string a)
{
char ch[35] = { '1', 'S', 'E', '*', 'Z', '*', '*', '8', '*', 'A', '*', '*', '*', '3', '*', '*', 'H', 'I', 'L', '*', 'J',
'M', '*', 'O', '*', '*', '*', '2', 'T', 'U', 'V', 'W', 'X', 'Y', '5' };
int len = a.length();
if (len % 2 == 0)
len = len / 2 - 1;
else
len = len / 2;
for (int i = 0; i <= len; i++)
{
if (isalpha(a.at(i)))
{
if (ch[a.at(i) - 'A' + 9] == '*')
return false;
a.at(i) = ch[a.at(i) - 'A' + 9];
}
if (isdigit(a.at(i)))
{
if (ch[a.at(i) - '1'] == '*')
return false;
a.at(i) = ch[a.at(i) - '1'];
}
}
return regular(a);
}
int main()
{
string a;
while (cin>>a)
{
bool reg = regular(a);
bool mir = mirror(a);
if (reg && mir)
{
cout << a;
printf(" -- is a mirrored palindrome.\n\n");
}
else if (!reg && mir)
{
cout << a;
printf(" -- is a mirrored string.\n\n");
}
else if (reg && !mir)
{
cout << a;
printf(" -- is a regular palindrome.\n\n");
}
else if (!reg && !mir)
{
cout << a;
printf(" -- is not a palindrome.\n\n");
}
}
}
Re: why wa in uva-401??
Posted: Wed Jun 11, 2014 8:24 pm
by brianfry713
A3A is a regular palindrome.
Re: 401-Palindromes Why getting WA
Posted: Mon Jun 23, 2014 3:58 pm
by blackheartadhar
Re: 401-Palindromes Why getting WA
Posted: Mon Jun 23, 2014 9:15 pm
by lbv
blackheartadhar wrote:Getting WA! Please help.
From the output specification:
In addition, after each output line, you must print an empty line. There are no exceptions for the last test case.
In addition, try the cases:
Input
Output
Code: Select all
3QE -- is not a palindrome.
Z55 -- is not a palindrome.
Re: 401-Palindromes Why getting WA
Posted: Tue Jun 24, 2014 11:31 am
by blackheartadhar
Now I'm getting Compile error!
Re: 401-Palindromes Why getting WA
Posted: Tue Jun 24, 2014 6:03 pm
by lbv
blackheartadhar wrote:Now I'm getting Compile error!
I have just submitted the latest code you posted as-is, and got AC. Maybe you submitted the wrong file? Or forgot to comment the freopen lines?
Re: 401-Palindromes Why getting WA
Posted: Thu Jun 26, 2014 5:57 am
by lichtgestalt01
here's some input cases i tried
Input:
Code: Select all
2BBS
B2SB
BBB
BBBB
AAA
AAAA
HII
O
X
B
xX
b
Output:
Code: Select all
2BBS -- is not a palindrome.
B2SB -- is not a palindrome.
BBB -- is a regular palindrome.
BBBB -- is a regular palindrome.
AAA -- is a mirrored palindrome.
AAAA -- is a mirrored palindrome.
HII -- is not a palindrome.
O -- is a mirrored palindrome.
X -- is a mirrored palindrome.
B -- is a regular palindrome.
xX -- is not a palindrome.
b -- is a regular palindrome.