451 - Poker Solitaire Evaluator
Moderator: Board moderators
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
451 - Poker
Could anyone help me with this problem ?
I try to solve this after when I solved problem 10315 (Poker Hands). I use the same checker function, but I got WA many times .... Is any trap (or traps) in this question ??
Thanks for help
I try to solve this after when I solved problem 10315 (Poker Hands). I use the same checker function, but I got WA many times .... Is any trap (or traps) in this question ??
Thanks for help
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany
Read this:
Straight: the five cards of the hand may be sorted on rank so that an unbroken sequence of 5 ranks is formed and the hand does not qualify for any of the following.
--> There can be cycle through Ace. <--
That is AC, 2H, 4D, 3H, 5S forms a straight, as does JH, XD,QC, KD, AS and QC, KD, AS, 2H, 3D.
Straight: the five cards of the hand may be sorted on rank so that an unbroken sequence of 5 ranks is formed and the hand does not qualify for any of the following.
--> There can be cycle through Ace. <--
That is AC, 2H, 4D, 3H, 5S forms a straight, as does JH, XD,QC, KD, AS and QC, KD, AS, 2H, 3D.
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
Pls help me! Problem - 451. Poker Solitaire Evaluator.

I'm solved "Poker Solitaire Evaluator" Problem.
But i got WA..
but I can't find the bug.
please help me
This is C++ Code.
[cpp]
#include <iostream.h>
class poker {
public:
char suja;
char munja;
};
poker po[5][5];
int posu[9];int sp(class poker sm[5]);
int fc(class poker sm[5]);
int fh(class poker sm[5]);
int pl(class poker sm[5]);
int st(class poker sm[5]);
int tr(class poker sm[5]);
int tp(class poker sm[5]);
int op(class poker sm[5]);
int np(class poker sm[5]);
void input();
void output();
void process();
void main()
{
input();
process();
output();
}
void input()
{
int i,j;
for(i=0;i<5;i++)
for(j=0;j<5;j++)
cin>>po[j].suja>>po[j].munja;
}
void process()
{
poker temp[5];
int i;
for(i=0;i<5;i++)
{
// cin>>temp[0].suja>>temp[0].munja>>temp[1].suja;
// cin>>temp[1].munja>>temp[2].suja>>temp[2].munja;
// cin>>temp[3].suja>>temp[3].munja>>temp[4].suja>>temp[4].munja;
temp[0]=po[0];
temp[1]=po[1];
temp[2]=po[2];
temp[3]=po[3];
temp[4]=po[4];
if(sp(temp)==1)
posu[8]++;
else if(fc(temp)==1)
posu[7]++;
else if(fh(temp)==1)
posu[6]++;
else if(pl(temp)==1)
posu[5]++;
else if(st(temp)==1)
posu[4]++;
else if(tr(temp)==1)
posu[3]++;
else if(tp(temp)==1)
posu[2]++;
else if(op(temp)==1)
posu[1]++;
else if(np(temp)==1)
posu[0]++;
}
for(i=0;i<5;i++)
{
temp[0]=po[0];
temp[1]=po[1];
temp[2]=po[2];
temp[3]=po[3][i];
temp[4]=po[4][i];
if(sp(temp)==1)
posu[8]++;
else if(fc(temp)==1)
posu[7]++;
else if(fh(temp)==1)
posu[6]++;
else if(pl(temp)==1)
posu[5]++;
else if(st(temp)==1)
posu[4]++;
else if(tr(temp)==1)
posu[3]++;
else if(tp(temp)==1)
posu[2]++;
else if(op(temp)==1)
posu[1]++;
else if(np(temp)==1)
posu[0]++;
}
}
void output()
{
int i;
for(i=0;i<8;i++)
cout<<posu[i]<<", ";
cout<<posu[8]<<endl;
}
int sp(class poker sm[])
{
if(st(sm) && pl(sm))
return 1;
return 0;
}
int fc(class poker sm[5])
{
int gasu[15]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[1]++;
gasu[14]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
gasu[sm[i].suja-48]++;
for(i=0;i<15;i++)
if(gasu[i]==4)
return 1;
return 0;
}
int fh(class poker sm[5])
{
int gasu[15]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[1]++;
gasu[14]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
gasu[sm[i].suja-48]++;
int flag=0,flag1=0;
for(i=0;i<15;i++)
if(gasu[i]==2)
flag=1;
else if(gasu[i]==3)
flag1=1;
if(flag==1 && flag1==1)
return 1;
return 0;
}
int pl(class poker sm[5])
{
int gasu[15]={0,};
int i;
for(i=0;i<5;i++)
{
if( sm[i].munja == 'S')
gasu[1]++;
if( sm[i].munja == 'H')
gasu[2]++;
if( sm[i].munja == 'D')
gasu[3]++;
if( sm[i].munja == 'C')
gasu[4]++;
}
for(i=0;i<5;i++)
if(gasu[i]==5)
return 1;
return 0;
}
int st(class poker sm[5])
{
int gasu[15]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[1]++;
gasu[14]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
gasu[sm[i].suja-48]++;
for(i=0;i<15;i++)
if(gasu[i]==1)
if(gasu[i+1]==1 && gasu[i+2]==1 && gasu[i+3]==1 && gasu[i+4]==1)
return 1;
return 0;
}
int tr(class poker sm[5])
{
int gasu[15]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[14]++;
gasu[1]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
gasu[sm[i].suja-48]++;
int flag=0,flag1=0;
for(i=0;i<15;i++)
if(gasu[i]==3)
return 1;
return 0;
}
int tp(class poker sm[5])
{
int gasu[15]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[1]++;
gasu[14]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
gasu[sm[i].suja-48]++;
int flag=0,flag1=0;
for(i=0;i<15;i++)
if(gasu[i]==2&& flag==0)
flag=1;
else if(gasu[i]==2 && flag==1)
flag1=1;
if(flag==1 && flag1==1)
return 1;
return 0;
}
int op(class poker sm[5])
{
int gasu[15]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[14]++;
gasu[1]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
gasu[sm[i].suja-48]++;
int flag=0,flag1=0;
for(i=0;i<15;i++)
if(gasu[i]==2)
return 1;
return 0;
}
int np(class poker sm[5])
{
return 1;
}
[/cpp]
I want the bug, ㅡ_ㅡ












I try. But I can not solve it. help me more
I try to solve with your help.
But I Can't solve problem with WA.
Help me Some more.
Modified source :
[cpp]
#include <iostream.h>
class poker {
public:
char suja;
char munja;
};
poker po[5][5];
int posu[9];
int sp(class poker sm[5]);
int fc(class poker sm[5]);
int fh(class poker sm[5]);
int pl(class poker sm[5]);
int st(class poker sm[5]);
int tr(class poker sm[5]);
int tp(class poker sm[5]);
int op(class poker sm[5]);
int np(class poker sm[5]);
void input();
void output();
void process();
void main()
{
input();
process();
output();
}
void input()
{
int i,j;
for(i=0;i<5;i++)
for(j=0;j<5;j++)
cin>>po[j].suja>>po[j].munja;
}
void process()
{
poker temp[5];
int i;
for(i=0;i<5;i++)
{
temp[0]=po[0];
temp[1]=po[1];
temp[2]=po[2];
temp[3]=po[3];
temp[4]=po[4];
if(sp(temp)==1)
posu[8]++;
else if(fc(temp)==1)
posu[7]++;
else if(fh(temp)==1)
posu[6]++;
else if(pl(temp)==1)
posu[5]++;
else if(st(temp)==1)
posu[4]++;
else if(tr(temp)==1)
posu[3]++;
else if(tp(temp)==1)
posu[2]++;
else if(op(temp)==1)
posu[1]++;
else if(np(temp)==1)
posu[0]++;
}
for(i=0;i<5;i++)
{
temp[0]=po[0];
temp[1]=po[1];
temp[2]=po[2];
temp[3]=po[3][i];
temp[4]=po[4][i];
if(sp(temp)==1)
posu[8]++;
else if(fc(temp)==1)
posu[7]++;
else if(fh(temp)==1)
posu[6]++;
else if(pl(temp)==1)
posu[5]++;
else if(st(temp)==1)
posu[4]++;
else if(tr(temp)==1)
posu[3]++;
else if(tp(temp)==1)
posu[2]++;
else if(op(temp)==1)
posu[1]++;
else if(np(temp)==1)
posu[0]++;
}
}
void output()
{
int i;
for(i=0;i<8;i++)
cout<<posu[i]<<", ";
cout<<posu[8]<<endl;
}
int sp(class poker sm[])
{
if(st(sm) && pl(sm))
return 1;
return 0;
}
int fc(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[1]++;
gasu[14]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
{
gasu[sm[i].suja-48]++;
gasu[sm[i].suja-48+13]++;
}
for(i=0;i<30;i++)
if(gasu[i]==4)
return 1;
return 0;
}
int fh(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[1]++;
gasu[14]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
{
gasu[sm[i].suja-48]++;
gasu[sm[i].suja-48+13]++;
}
int flag=0,flag1=0;
for(i=0;i<30;i++)
if(gasu[i]==2)
flag=1;
else if(gasu[i]==3)
flag1=1;
if(flag==1 && flag1==1)
return 1;
return 0;
}
int pl(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
{
if( sm[i].munja == 'S')
gasu[1]++;
if( sm[i].munja == 'H')
gasu[2]++;
if( sm[i].munja == 'D')
gasu[3]++;
if( sm[i].munja == 'C')
gasu[4]++;
}
for(i=0;i<5;i++)
if(gasu[i]==5)
return 1;
return 0;
}
int st(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[1]++;
gasu[14]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
{
gasu[sm[i].suja-48]++;
gasu[sm[i].suja-48+13]++;
}
for(i=0;i<30;i++)
if(gasu[i]==1)
if(gasu[i+1]==1 && gasu[i+2]==1 && gasu[i+3]==1 && gasu[i+4]==1)
return 1;
return 0;
}
int tr(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[14]++;
gasu[1]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
{
gasu[sm[i].suja-48]++;
gasu[sm[i].suja-48+13]++;
}
int flag=0,flag1=0;
for(i=0;i<15;i++)
if(gasu[i]==3)
return 1;
return 0;
}
int tp(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[1]++;
gasu[14]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
{
gasu[sm[i].suja-48]++;
gasu[sm[i].suja-48+13]++;
}
int flag=0,flag1=0;
for(i=0;i<15;i++)
if(gasu[i]==2&& flag==0)
flag=1;
else if(gasu[i]==2 && flag==1)
flag1=1;
if(flag==1 && flag1==1)
return 1;
return 0;
}
int op(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[14]++;
gasu[1]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
{
gasu[sm[i].suja-48]++;
gasu[sm[i].suja-48+13]++;
}
int flag=0,flag1=0;
for(i=0;i<15;i++)
if(gasu[i]==2)
return 1;
return 0;
}
int np(class poker sm[5])
{
return 1;
}
[/cpp]
Thank.
But I Can't solve problem with WA.
Help me Some more.
Modified source :
[cpp]
#include <iostream.h>
class poker {
public:
char suja;
char munja;
};
poker po[5][5];
int posu[9];
int sp(class poker sm[5]);
int fc(class poker sm[5]);
int fh(class poker sm[5]);
int pl(class poker sm[5]);
int st(class poker sm[5]);
int tr(class poker sm[5]);
int tp(class poker sm[5]);
int op(class poker sm[5]);
int np(class poker sm[5]);
void input();
void output();
void process();
void main()
{
input();
process();
output();
}
void input()
{
int i,j;
for(i=0;i<5;i++)
for(j=0;j<5;j++)
cin>>po[j].suja>>po[j].munja;
}
void process()
{
poker temp[5];
int i;
for(i=0;i<5;i++)
{
temp[0]=po[0];
temp[1]=po[1];
temp[2]=po[2];
temp[3]=po[3];
temp[4]=po[4];
if(sp(temp)==1)
posu[8]++;
else if(fc(temp)==1)
posu[7]++;
else if(fh(temp)==1)
posu[6]++;
else if(pl(temp)==1)
posu[5]++;
else if(st(temp)==1)
posu[4]++;
else if(tr(temp)==1)
posu[3]++;
else if(tp(temp)==1)
posu[2]++;
else if(op(temp)==1)
posu[1]++;
else if(np(temp)==1)
posu[0]++;
}
for(i=0;i<5;i++)
{
temp[0]=po[0];
temp[1]=po[1];
temp[2]=po[2];
temp[3]=po[3][i];
temp[4]=po[4][i];
if(sp(temp)==1)
posu[8]++;
else if(fc(temp)==1)
posu[7]++;
else if(fh(temp)==1)
posu[6]++;
else if(pl(temp)==1)
posu[5]++;
else if(st(temp)==1)
posu[4]++;
else if(tr(temp)==1)
posu[3]++;
else if(tp(temp)==1)
posu[2]++;
else if(op(temp)==1)
posu[1]++;
else if(np(temp)==1)
posu[0]++;
}
}
void output()
{
int i;
for(i=0;i<8;i++)
cout<<posu[i]<<", ";
cout<<posu[8]<<endl;
}
int sp(class poker sm[])
{
if(st(sm) && pl(sm))
return 1;
return 0;
}
int fc(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[1]++;
gasu[14]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
{
gasu[sm[i].suja-48]++;
gasu[sm[i].suja-48+13]++;
}
for(i=0;i<30;i++)
if(gasu[i]==4)
return 1;
return 0;
}
int fh(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[1]++;
gasu[14]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
{
gasu[sm[i].suja-48]++;
gasu[sm[i].suja-48+13]++;
}
int flag=0,flag1=0;
for(i=0;i<30;i++)
if(gasu[i]==2)
flag=1;
else if(gasu[i]==3)
flag1=1;
if(flag==1 && flag1==1)
return 1;
return 0;
}
int pl(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
{
if( sm[i].munja == 'S')
gasu[1]++;
if( sm[i].munja == 'H')
gasu[2]++;
if( sm[i].munja == 'D')
gasu[3]++;
if( sm[i].munja == 'C')
gasu[4]++;
}
for(i=0;i<5;i++)
if(gasu[i]==5)
return 1;
return 0;
}
int st(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[1]++;
gasu[14]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
{
gasu[sm[i].suja-48]++;
gasu[sm[i].suja-48+13]++;
}
for(i=0;i<30;i++)
if(gasu[i]==1)
if(gasu[i+1]==1 && gasu[i+2]==1 && gasu[i+3]==1 && gasu[i+4]==1)
return 1;
return 0;
}
int tr(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[14]++;
gasu[1]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
{
gasu[sm[i].suja-48]++;
gasu[sm[i].suja-48+13]++;
}
int flag=0,flag1=0;
for(i=0;i<15;i++)
if(gasu[i]==3)
return 1;
return 0;
}
int tp(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[1]++;
gasu[14]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
{
gasu[sm[i].suja-48]++;
gasu[sm[i].suja-48+13]++;
}
int flag=0,flag1=0;
for(i=0;i<15;i++)
if(gasu[i]==2&& flag==0)
flag=1;
else if(gasu[i]==2 && flag==1)
flag1=1;
if(flag==1 && flag1==1)
return 1;
return 0;
}
int op(class poker sm[5])
{
int gasu[30]={0,};
int i;
for(i=0;i<5;i++)
if(sm[i].suja=='A')
{
gasu[14]++;
gasu[1]++;
}
else if(sm[i].suja=='X')
gasu[10]++;
else if(sm[i].suja=='J')
gasu[11]++;
else if(sm[i].suja=='Q')
gasu[12]++;
else if(sm[i].suja=='K')
gasu[13]++;
else
{
gasu[sm[i].suja-48]++;
gasu[sm[i].suja-48+13]++;
}
int flag=0,flag1=0;
for(i=0;i<15;i++)
if(gasu[i]==2)
return 1;
return 0;
}
int np(class poker sm[5])
{
return 1;
}
[/cpp]
Thank.
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
451 - Poker Solitaire Evaluator
Could anyone tel me, why this code causes WA ??
I'm really frustrated, beacause I solve other poker problem (and I use the same algorithm) ......
Best regards
Dominik Michniewski
I'm really frustrated, beacause I solve other poker problem (and I use the same algorithm) ......
Best regards
Dominik Michniewski
Code: Select all
I cut it off, because it's now a spoiler :(
Last edited by Dominik Michniewski on Fri Feb 28, 2003 12:17 pm, edited 1 time in total.
-
- Experienced poster
- Posts: 192
- Joined: Sat Nov 30, 2002 5:14 am
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
scanf() avoids blank and empty lines, so this code correct handle multiple input ... I think, that error must be somewhere else, but I don't imagine where ...
Dominik Michniewski
Dominik Michniewski
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Born from ashes - restarting counter of problems (800+ solved problems)
-
- Experienced poster
- Posts: 192
- Joined: Sat Nov 30, 2002 5:14 am
Hi, Dominik..
RS. 

Code: Select all
input:
2
AS 2S 3S 4S 5S
AC 2H 3H 5C 4C
AH 2D KC KH 5D
AD 3D KD 9D 8D
XH 3C XC XS 8C
AS 2S 3S 4S 5S
AC 2H 3H 5C 4C
AH 2D KC KH 5D
AD 3D KD 9D 8D
XH 3C XC XS 8C
AS 2S 3S 4S 5S
AC 2H 3H 5C 4C
AH 2D KC KH 5D
AD 3D KD 9D 8D
XH 3C XC XS 8C
AS 2S 3S 4S 5S
AC 2H 3H 5C 4C
AH 2D KC KH 5D
AD 3D KD 9D 8D
XH 3C XC XS 8C
AS 2S 3S 4S 5S
AC 2H 3H 5C 4C
AH 2D KC KH 5D
AD 3D KD 9D 8D
XH 3C XC XS 8C
Code: Select all
Your output:
1, 1, 2, 1, 1, 1, 1, 1, 1
1, 1, 2, 1, 1, 1, 1, 1, 1
Code: Select all
The Output should be :
1, 1, 2, 1, 1, 1, 1, 1, 1
1, 1, 2, 1, 1, 1, 1, 1, 1
1, 1, 2, 1, 1, 1, 1, 1, 1
1, 1, 2, 1, 1, 1, 1, 1, 1
1, 1, 2, 1, 1, 1, 1, 1, 1

-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
Hmmm ....
If I see correct (but I don't find it in problem specs)
one part of input could be build with more than one deck ????????
It's no fair
Try this and maybe got accepted
)
Thanks Red Scorpion for help
)
Dominik
If I see correct (but I don't find it in problem specs)


It's no fair

Try this and maybe got accepted

Thanks Red Scorpion for help

Dominik
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Born from ashes - restarting counter of problems (800+ solved problems)
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
I change my reading part to this: (in place of for loop with scanf() and Convert() ):
But still got WA. I got now the same result as yours Red Scorpion. Some other thoughts ? Maybe I did something wrong ? Maybe there are input with less than five cards in one line ? Could anyone tell something about it ?
Best regards
Dominik
Code: Select all
while(gets(line) != NULL)
{
if(line[0] == 0) break;
j = 0;
do
{
sscanf(line,"%s %s %s %s %s",c1,c2,c3,c4,c5);
all[j + 0] = Convert(c1);
all[j + 1] = Convert(c2);
all[j + 2] = Convert(c3);
all[j + 3] = Convert(c4);
all[j + 4] = Convert(c5);
j += 5;
if(j < 25) gets(line);
}
while(j < 25);
....
Best regards
Dominik
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Born from ashes - restarting counter of problems (800+ solved problems)
-
- Experienced poster
- Posts: 192
- Joined: Sat Nov 30, 2002 5:14 am
HI,
Your Output still wrong!
RS.

Code: Select all
Another sample input:
1
5S 2S 3S 4S 7S
AS 2S 3S 4S 5S
5S 6S 7S 8S 9S
JS 5S 6S 7S 8S
KS JS QS AS JS
Your output:
0, 0, 0, 0, 0, 9, 0, 0, 1
My Output:
0, 0, 0, 0, 0, 8, 0, 0, 2

RS.

-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
Red Scorpion, you should be guru instead of me
:D:D:D
I made a silly mistake : instead of
should be
Thanks all for help
and best luck for every person in this site
especialy for Red Scorpion and Adrian Kuegel 
Dominik

I made a silly mistake : instead of
Code: Select all
for(i=1;i<5;i++) if(x[i-1] != x[i] + 1) break;
if(i >= 5) straight = 1;
Code: Select all
for(i=1;i<5;i++) if(x[i] != x[i-1] + 1) break;
if(i >= 5) straight = 1;



Dominik
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Born from ashes - restarting counter of problems (800+ solved problems)
#10315: Poker Hands
Hey Dominik:
Regarding problem #10315-Poker Hands. Is this how you solve it, like you start off with "straight flush" and work your way through to "pair". In case of a tie or if none of these above work, you compare the card for the "high card".
I was wondering if there is any other way to solve this problem, like is there anyway to use a numeric value to find out who wins? I was told by someone that there is a way to do it by using a single numeric value of each poker hand and do a comparison on that.
I appreciate your help.
Thanks.
Regarding problem #10315-Poker Hands. Is this how you solve it, like you start off with "straight flush" and work your way through to "pair". In case of a tie or if none of these above work, you compare the card for the "high card".
I was wondering if there is any other way to solve this problem, like is there anyway to use a numeric value to find out who wins? I was told by someone that there is a way to do it by using a single numeric value of each poker hand and do a comparison on that.
I appreciate your help.
Thanks.
Give a man an answer, and he's satisfied today. Teach him to program, and he will be frustrated for the rest of his life. [Anonymous]