10315 - Poker Hands

All about problems in Volume 103. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

kvee119
New poster
Posts: 2
Joined: Tue Sep 16, 2003 3:37 am
Contact:

10315 - Poker Hands

Post by kvee119 »

Somebody can tell me why I get "invalid memory reference Error" or "Runtime Error (SIGSEGV)". Someone pls give me some inputs. I cannot find my bugs.

[cpp]
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>

using namespace std;

#ifdef ONLINE_JUDGE
#define offline(x)
#define fin stdin
#define fout stdout
#else
#define offline(x) x
FILE * fin, *fout;
#endif
void prompt(){
fflush(stdin); fflush(stdout);
offline(getchar());
}
void initFiles(){
offline(fin = fopen("10315.inp","r"));
offline(fout = fopen("10315.out","w"));
}
void closeFiles(){
offline(fclose(fin));
offline(fclose(fout));
}

void errorif(bool err = true){
int i = 0;
if (err){
printf("error occured\n");
offline(prompt());
i = 1 % i;
}
}
#define fout stdout

void make(char inp[5][5], int score[2]);

void main(){
char inp1[5][5],inp2[5][5];
int score1[2],score2[2];

initFiles();
while (fscanf(fin,"%s %s %s %s %s %s %s %s %s %s",inp1[0],inp1[1],inp1[2],inp1[3],inp1[4],inp2[0],inp2[1],inp2[2],inp2[3],inp2[4]) != EOF) {
make(inp1,score1);
make(inp2,score2);
if (score1[0] == score2[0] && score1[1] == score2[1]) {
fprintf(fout,"Tie.\n");
continue;
}

if ((score1[0] > score2[0]) || (score1[0] == score2[0] && score1[1] > score2[1])){
fprintf(fout,"Black wins.\n");
}
else {
fprintf(fout,"White wins.\n");
}
}

offline(prompt());
closeFiles();
}

void make(char input[5][5], int score[2]) {
int i,j,max,temp;
int inp[5][2];
int flush,triple,double1,double2,forple,straight;
int flag[15];

//change hand from char to int
for (i=0; i<5; i++) {
switch (input[0]) {
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
inp[0] = input[0] - '0';
break;
case 'T':
inp[0] = 10;
break;
case 'J':
inp[0] = 11;
break;
case 'Q':
inp[0] = 12;
break;
case 'K':
inp[0] = 13;
break;
case 'A':
inp[0] = 14;
break;
default :
inp[0] = 1;
break;
}

switch (input[1]) {
case 'C':
inp[i][1] = 1;
break;
case 'D':
inp[i][1] = 2;
break;
case 'H':
inp[i][1] = 3;
break;
case 'S':
inp[i][1] = 4;
break;
default:
inp[i][1] = 0;
break;
}
}

//sort cards in the hand in descending order
for (i=0; i<5; i++) {
max = i;
for (j=i+1; j<5; j++) {
if (inp[max][0] < inp[j][0]) max = j;
}

temp = inp[max][0];
inp[max][0] = inp[i][0];
inp[i][0] = temp;

temp = inp[max][1];
inp[max][1] = inp[i][1];
inp[i][1] = temp;
}

//flag flush
if (inp[0][1] == inp[1][1] && inp[0][1] == inp[2][1] && inp[0][1] == inp[3][1] && inp[0][1] == inp[4][1])
flush = 1;
else flush = 0;

//flag straight
if (inp[0][0] == inp[1][0] + 1 && inp[0][0] == inp[2][0] + 2 && inp[0][0] == inp[3][0] + 3 && inp[0][0] == inp[4][0] + 4)
straight = 1;
else straight = 0;

//flag cards in an array
for (i=0; i<15; i++)
flag[i] = 0;
for (i=0; i<5; i++)
flag[inp[i][0]]++;

//ini doub,triple,forple
double1 = 0; double2 = 0; triple = 0; forple = 0;
for (i=14; i>=2; i--) {
switch (flag[i]) {
case 2:
if (double1 == 0) double1 = i;
else double2 = i;
break;
case 3:
triple = i;
break;
case 4:
forple = i;
break;
default:
break;
}
}

//make array 'score'
if (straight && flush) {
score[0] = 9;
score[1] = inp[0][0];
return;
}

if (forple) {
score[0] = 8;
score[1] = forple;
return;
}

if (triple && double1) {
score[0] = 7;
score[1] = triple;
return;
}

if (flush) {
score[0] = 6;
score[1] = inp[0][0]*15*15*15*15 + inp[1][0]*15*15*15 + inp[2][0]*15*15 + inp[3][0]*15 + inp[4][0];
return;
}

if (straight) {
score[0] = 5;
score[1] = inp[0][0];
return;
}

if (triple) {
score[0] = 4;
score[1] = triple;
return;
}

if (double1 && double2) {
score[0] = 3;
int left;
for (i=1; i<=14; i++)
if (flag[i] == 1) left = i;
score[1] = double1*15*15 + double2*15 + i;
return;
}

if (double1) {
score[0] = 2;
int left1=0,left2=0,left3=0;
for (i=14; i>=1; i++)
if (flag[i]==1) {
if (left1 == 0) left1 = i;
else if (left2 == 0) left2 = i;
else left3 = i;
}
score[1] = double1*15*15*15 + left1*15*15 + left2*15 + left3;
return;
}

score[0] = 1;
score[1] = inp[0][0]*15*15*15*15 + inp[1][0]*15*15*15 + inp[2][0]*15*15 + inp[3][0]*15 + inp[4][0];
return;
}
[/cpp]
Give and Get
rbuchan
New poster
Posts: 27
Joined: Fri Feb 28, 2003 7:59 am
Contact:

Seg Fault

Post by rbuchan »

How is it that I can get a segmentation fault from the judge and not when running the test data? Does the judge have bad input? Here is what I have in terms of the input mode if someone has suggestions (I have done this portion in 4 or 5 different ways):

[cpp]
char cards[30];
while (gets(cards)) {
for (int i = 0, j = 0; i < 29; i += 3, j++) {
if (i < 15) {
b[j][0] = cards;
b[j][1] = cards[i+1];
}
else {
w[j-5][0] = cards;
w[j-5][1] = cards[i+1];
}
}
...
[/cpp]

Any help would be appreciated.
Cheers,
Ron
midra
Experienced poster
Posts: 119
Joined: Fri Feb 13, 2004 7:20 am
Contact:

10315 TLE

Post by midra »

Maybe there is an special Input that I haven't think it, or maybe it 's because my algorithm is so unefficient but I got TLE...
here is my code...
[c]
#include <stdio.h>

int main()
{
int i,j; /*counters*/
char card[40];
int pb=0,pw=0; /*player1=... player2=... p/comparar*/
int x=1; /*carta a examinar*/
int temp,tempb1,tempb2,tempw1,tempw2; /*Guarda valores de cartas rep*/
int repb1=1,repw1=1,repb2=1,repw2=1; /*Cuenta las repetidas*/
int cardhb=0,cardhw=0; /*la carta mas alta*/
while(1)
{
scanf("%c",&card[1]);
i=1;
goto b;
while(card!='\n')
{
i++;
scanf("%c",&card);
b:
if (card==' ')
i--;
else if (card=='T')
card-=26; /*T=10*/
else if (card=='J')
card-=15; /*J=11*/
else if (card=='Q')
card-=21; /*Q=12*/
else if (card=='K')
card[i]-=14; /*K=13*/
else if (card[i]=='A')
card[i]-=3; /*As=14*/
}

/*ordenar cartas*/

for (j=1;j<=7;j++)
for (i=1;i<=7;i=i+2)
if (card[i]>card[i+2]) /********************/
{ /* */
temp=card[i]; /* ordenar negras */
card[i]=card[i+2]; /* */
card[i+2]=temp; /********************/
}

for (j=1;j<=7;j++)
for (i=11;i<=17;i=i+2)
if (card[i]>card[i+2]) /********************/
{ /* */
temp=card[i]; /* ordenar blancas */
card[i]=card[i+2]; /* */
card[i+2]=temp; /********************/
}



temp=0;
if (card[9]==62 && card[1]==50)
temp++;
for (i=1;i<=7;i=i+2) /*Comprueba si hay escalera*/
if (card[i+2]-card[i]==1) /* en el player negro*/
temp++;
if (temp==4)
pb=5;

temp=0;
if (card[19]==62 && card[11]==50)
temp++;
for (i=11;i<=17;i=i+2) /*Comprueba si hay escalera*/
if (card[i+2]-card[i]==1) /* en el player blanco*/
temp++;
if (temp==4)
pw=5;

/* -------------------------BLACK CARDS-------------------------------*/


temp=0;
for (i=2;i<=8;i=i+2)
{
if (card[i]==card[i+2]) /*Son del mismo palo*/
temp++;
}
if (temp==4)
{
if (pb==5) /*Si ademas estan ordenados es ER*/
pb=9;
else if (pb==0) /*Sino de mientras es color*/
pb=6;
}

for (i=1;i<=7;i=i+2) /*
WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR »

Code: Select all

3H 3S 4D 5D 7D 2H 3H 4S 5S 7S

Code: Select all

Black wins.
midra
Experienced poster
Posts: 119
Joined: Fri Feb 13, 2004 7:20 am
Contact:

Post by midra »

Hi WR!
I don't understand very good what you mean...
In this Input:

Code: Select all

3H 3S 4D 5D 7D 2H 3H 4S 5S 7S 
My program returns "Black wins." and it is true that the black wins because the black are the first five cards and the black player has a pair (3H 3S) while the white player doesn't have anything....only a 7S that it's his high card...
Maybe you confuse with the Full, but the full it's for the value of the cards and not for the suits...

good bye!
WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR »

No, I just meant what I wrote. If your program's returning 'Black wins.' it's ok in that respect.

Another sample:

Code: Select all

3H 5H AH AH 3H 2H 2C AC AD 2D
3H 3D 6C 3S 3D 2H 2C AC AD 2D
3H 3D 6C 3S 3C 2H 2D 6D 2S 2C
2H 3H 4H 5H 6H AC AS AD AH KH
4H 5H 6H 7H 8H 8C 7C 6C 5C 4C

Code: Select all

White wins.
Black wins.
Black wins.
Black wins.
Tie.
midra
Experienced poster
Posts: 119
Joined: Fri Feb 13, 2004 7:20 am
Contact:

Post by midra »

Sorry, I have misunderstood..

Thanks for the samples! :D :D :D

Bye!
pablo
New poster
Posts: 4
Joined: Tue Nov 09, 2004 2:37 am

10315 interpretation problemas with straight

Post by pablo »

it is not stated in the problem if A-2-3-4-5 is a straight (when it only says consecutivew values)

if it IS to be considered a straight, it is a bigger one or a smaller one than, in example, 2-3-4-5-6 (because it says when you have two straights rank by their "highest card", which literally means thar A-2-3-4-5 is better than 2-3-4-5-6, but anyone who has played poker know that this is'nt true)

thanks
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

A is the highest and 2 is the lowest card, therefore they are _not_ consecutive and A-2-3-4-5 is _not_ a straight (flush).
pablo
New poster
Posts: 4
Joined: Tue Nov 09, 2004 2:37 am

why WA?

Post by pablo »

i dont know why this is giving me WA, i tested almost everything i came up with

Code: Select all

#pragma warning(disable:4786)
#include <cstdio>
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
#define forn(i,n) for(i=0;i<n;i++)

#define STRAIGHT_VALUE 14
#define FLUSH_VALUE 15

typedef long tint;
typedef pair<tint, tint> pint;
typedef vector< pint > hand;
typedef vector< tint > puntaje;
/*
points to each game
pair = 4
two pairs = 8
three of a kind = 12
straight = 14
flush = 15
full house = 16
poker = 24
straigh flush = 29;
cantPairs * 2 + isFlush + isStraight
*/
tint cantPairs(hand& m)
{
	tint i,j,pares=0;
	forn(i,m.size()) forn(j, m.size())
	{
		if (m[i].first == m[j].first) pares++;
	}
	return pares-m.size();
}

tint isStraight(hand& m)
{
	tint i;
	sort(m.begin(), m.end());
	forn(i, m.size()-1)
	{
		if (m[i].first != m[i+1].first - 1) return 0;
	}
	return STRAIGHT_VALUE;
}

tint isFlush(hand& m)
{
	tint i;
	forn(i, m.size()-1)
	{
		if (m[i].second != m[i+1].second) return 0;
	}
	return FLUSH_VALUE;
}

tint gamePoints(hand& m)
{
	return cantPairs(m) * 2 + isFlush(m) + isStraight(m);
}

puntaje points(hand& m)
{
	//r is a vector: 1st the points for the game and then the cards ordered first
	//by how many times it appears and then by value (so as to be compared 
	//in that order for decision in case of tie with gamepoints
	vector<tint> r;
	r.push_back(gamePoints(m));
	//cout << "juego: " << r[0] << endl;
	map<tint, tint> c;
	tint i;
	forn(i,m.size())
	{
		c[m[i].first]++;
	}
	vector<pint> cants;
	map<tint, tint>::iterator it;
	for(it = c.begin() ; it != c.end() ; ++it)
	{
		cants.push_back( pint( it->second, it->first ) );
	}
	sort(cants.begin(), cants.end());
	//cout << "cartas: ";
	forn(i, cants.size())
	{
		r.push_back(cants[cants.size()-1-i].second);
		//cout << r[r.size()-1] << " ";
	}
	//cout << endl;
	return r;
}

tint comp(hand& m1, hand& m2)
{
	puntaje n1 = points(m1);
	puntaje n2 = points(m2);
	return (n1 > n2 ? 1 : n1 == n2 ? 0 : -1);
}

tint convN(char c)
{
	switch(c)
	{
	case 'A': return 13;
	case 'K': return 12;
	case 'Q': return 11;
	case 'J': return 10;
	case 'T': return 9;
	}
	return c - '2';
}

pint readCard()
{
	string s;
	cin >> s;
	if (s == "") return pint(-1,-1);
	return pint(convN(s[0]), s[1]);
}

hand readHand()
{
	hand r;
	tint i;
	forn(i,5)
	{
		pint c = readCard();
		if (c == pint(-1,-1)) return hand();
		r.push_back(c);
	}
	return r;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
#endif

	while(true)
	{
		hand m1 = readHand();
		if (m1 == hand()) break;
		hand m2 = readHand();
		switch(comp(m1, m2))
		{
		case -1: cout << "White wins." << endl; break;
		case 0: cout << "Tie." << endl; break;
		case 1: cout << "Black wins." << endl; break;
		}
	}

	return 0;
}
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Try the following input output set..

Input:

Code: Select all

2H 3D 5S 9C KD 2C 3H 4S 8C AH
2H 4S 4C 2D 4H 2S 8S AS QS 3S
2H 3D 5S 9C KD 2C 3H 4S 8C KH
2H 3D 5S 9C KD 2D 3H 5C 9S KH
AH JH TH QH KH AD QD KD TD JD
AH JH TH QH KH KD 9D JD TD QD
KD 9D JD TD QD AH JH TH QH KH
AH JH TH QH KH AH JH TH QH KD
9H 7H 3H 8H KH KD 9D 3D 7D 2D
KD 9D 3D 7D 2D 9H 7H 3H 8H KH
KD 9D 3D 7D 2D 9H 7H 3H 2H KH
TH TD TS TC KD 9H 9D 9S 9C JD
8H 8S 8D 8C AC AC KD KH KC KS
AH AS AC 2D 2H KH KS 2S 2C KH
TS TC JH 2H TH TD 9D 9H 9C 3C
TD TC KD KC 2H TS TH 2H KH KS
TD TC KD 4C 2H TS TH 2S 4H KS
TD TC 2D 4C 2H TS TH 2S 2S KS
TD TC 2D 4C 2H TS TH 3S 3D KS
TD TC 2D 4C 2H JS JH 2S 2C 4S
TD TS KD JS 2S TH TC KC JD 3C
TD JH TS 3S 5D TH JS TC 3S 4C
TD JH TS 3S 5D TH QS TC 3S 5C
TD TS QH KH AH JH JD 2H 3S 4C
AH 2H 3H 4H 5H 6H 6D 6C 7C 6S
Output:

Code: Select all

White wins.
Black wins.
Black wins.
Tie.
Tie.
Black wins.
White wins.
Black wins.
Black wins.
White wins.
Tie.
Black wins.
White wins.
Black wins.
Black wins.
Tie.
Tie.
White wins.
White wins.
White wins.
White wins.
Black wins.
White wins.
White wins.
White wins.
Hope it helps... :)
Ami ekhono shopno dekhi...
HomePage
liangchene
New poster
Posts: 12
Joined: Thu May 19, 2005 6:07 am

Post by liangchene »

Jan, I got all the output right, and I tests many cases on my own, the judege still tells me I get the wrong answer.

Here is my source code

Code: Select all

#include<iostream>
#include<fstream>
#include<string>
#include<vector>
using namespace std;

//ifstream cin ("haha.txt");

struct card
{
  long long num;
  char suit;
};

long long value (char a)
{
 switch (a)
 {
  case 'A': return 14;
  case '2': return 2;
  case '3': return 3;
  case '4': return 4;
  case '5': return 5;
  case '6': return 6;
  case '7': return 7;
  case '8': return 8;
  case '9': return 9;
  case 'T': return 10;
  case 'J': return 11;                
  case 'Q': return 12;
  case 'K': return 13;
 }
}

long long straight(card cards1[5])
{
 vector<int> cards;
 int x;
 for (x=0;x<5;x++)
 {
  cards.push_back(cards1[x].num);
 }
 sort(cards.begin(),cards.end());
 
 if( cards[0]==cards[1]-1 &&cards[0]==cards[2]-2 && cards[0]==cards[3]-3 && cards[0]==cards[4]-4)
 return cards[4];
 
 //now , for the cycles
 //we increase 2,3,4,5 into 15,16,17,18
 /*
 for (x=0;x<5;x++)
 {
  if (cards[x]>=2 && cards[x]<=5)
  {
   cards[x]+=13;
  }
 }
 sort(cards.begin(),cards.end());
 
 if( cards[0]==cards[1]-1 &&cards[0]==cards[2]-2 && cards[0]==cards[3]-3 && cards[0]==cards[4]-4)
 return 14;
 */
 return 0;
}

long long twopairs(card cards1[5])
{
 long long counts[15];
 long long x;
 long long card_value1=0,card_value2=0;
 vector<long long> num;
 long long score=0;
 for (x=0;x<15;x++)
 {
  counts [x]= 0;
 }
 for (x=0;x<5;x++)
 {
  counts [cards1[x].num]++;
 }
 long long counter =0;
 
 for (x=0;x<15;x++)
 {
  if (counts[x]==2)
  {
   counter ++;
   if (x >card_value2)
   card_value2=x;
   else
   card_value1=x;
  }
 }
 
 if (counter ==2)
 {
     for (x=0;x<15;x++)
     {
      if (counts[x]==1)
      {
       num.push_back(x);                   
      }
     }     
      score+=(card_value2<<(4*7))+card_value1<<(4*6);
      sort(num.begin(),num.end());   
  
      for (x=0;x<1;x++)
      {
       score+= (num[x]<<(x+1)*4);
      }
     return score;
   }
 return 0;
}

long long pairs (card cards1[5])
{
  long long counts[15];
 long long x;
 long long card_value;
 long long counter=0;
 long long score=0;
 vector<long long> num;
 
 for (x=0;x<15;x++)
 {
  counts [x]= 0;
 }
 for (x=0;x<5;x++)
 {
  counts [cards1[x].num]++;
 }
 
 for (x=0;x<15;x++)
 {
  if (counts[x]==2)
  {
   counter ++;
   card_value = x;
  }
 }

  score +=(card_value<<6*4);
  
 if (counter ==1)
 {
 for (x=0;x<15;x++)
 {
  if (counts[x]==1)
  {
   num.push_back(x);                   
  }
 }     
 
  sort(num.begin(),num.end());   
  for (x=0;x<3;x++)
  {
   score+= (num[x]<<(x+1)*4);
  }
  
  return score;
 }
 return 0;
}

long long score_cal(card cards1[5])
{
  vector<long long> cards;
  long long x;
  long long score =0;
  long long a=2;
  for (x=0;x<5;x++)
   cards.push_back(cards1[x].num);
   
   sort(cards.begin(),cards.end());

   if (cards1[0].suit==cards1[1].suit && cards1[0].suit==cards1[2].suit && cards1[0].suit==cards1[3].suit &&cards1[0].suit==cards1[4].suit && straight(cards1) > 0)//now for straight flush      
   {
    //13
    cout<<"Straight flush"<<endl;
    score+= (straight(cards1)<<(13*4)) ;    
   }
   //four of a kind
   else if ((cards[0] == cards[1] && cards[0] == cards[2] && cards[0] == cards[3]) || (cards[4] == cards[1] && cards[4] == cards[2] && cards[4] == cards[3]))
   {
    //12
    cout<<"Four of a kind";
    score+= (cards[1]<<(12*4));
   }
   
   //full house
   else if (cards[0] == cards[1] && cards[0] == cards[2] && cards[3] == cards[4])
   {
    //11
    cout<<"full house"<<endl;
    score+= (cards[0]<<(11*4));      
   }   
   else if (cards[0] == cards[1] && cards[2] == cards[3] && cards[2] == cards[4])
   {
    //11
    cout<<"full house"<<endl;
    score+= (cards[4]<<(11*4));          
   }   
   
   //flush
   else if (cards1[0].suit==cards1[1].suit && cards1[0].suit==cards1[2].suit && cards1[0].suit==cards1[3].suit &&cards1[0].suit==cards1[4].suit)
   {
    //10
    cout<<"flush"<<endl;
    score += (a<<(10*4));
     for (x=0;x<5;x++)
   score+= (cards[x]<<4*(x+1));     
   }   
   //straight
   else if (straight(cards1)>0)
   {
    //9
    cout<<"straight"<<endl;
    score += (straight(cards1)<<(9*4));    
   }
   //three of a kind
   else if ( (cards[0] == cards[1] && cards[0] == cards[2]) || (cards[1] == cards[2] && cards[1] == cards[3]) || (cards[2] == cards[3] && cards[2] == cards[4]))
   {
    cout<<"three of a kind"<<endl;
    //8
    score += (cards[2]<<(8*4));
   }
//two pairs
   else if (twopairs(cards1)>0)
   {
   //7 //6
   cout<<"two pairs"<<endl;
   score+= twopairs(cards1);           
   }
//pair
   else if (pairs(cards1)>0)
   {
    cout<<"pair"<<endl;
    score+= pairs(cards1);   
   }
//high card
   else 
   {
    cout<<"high card"<<endl;
    for (x=0;x<5;x++)
    {        
     score+= (cards[x]<<4*(x+1));        
    }
   }
   return score;
}
int main()
{
 long long x;
 card dummy;
 card black[5];
 card white[5];
 long long score_b;
 long long score_w;
 char suit;
 char num1;

 while(cin>>num1)
 {  
  cin>>dummy.suit;
  dummy.num= value(num1);
  black[0]=dummy;
  for (x=1;x<5;x++)
  {
   cin>>num1;
   dummy.num= value(num1);
   cin>>dummy.suit;
   black[x]= dummy;
  }  
  
  for (x=0;x<5;x++)
  {
  cin>>num1;
   dummy.num= value(num1);
   cin>>dummy.suit;
   white[x]= dummy;   
  }
  //now we got all the cards.
  //since we have 13 cards, we will each time multiply by 16.
  //start from the highest one
  //high cards
  //first of all, we rank the cards
  score_b =   score_cal(black);
  score_w =   score_cal(white);  

   if (score_b> score_w) cout<< "Black wins."<<endl;
   else if (score_b< score_w) cout<<"White wins."<<endl;
   else cout<<"Tie."<<endl;
  // cout<<score_b<<' '<<score_w<<endl;

 }
 system("pause");
 return 0;
}

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Your code returned compile error when I submitted it to the judge. My compiler was unable to compile the following line..

Code: Select all

sort(cards.begin(),cards.end()); 
And the rest are almost ok. Execpt that you are printing every position like "high card", "pair". Fix the errors and submit. If you still get WA, inform me.
Ami ekhono shopno dekhi...
HomePage
liangchene
New poster
Posts: 12
Joined: Thu May 19, 2005 6:07 am

Post by liangchene »

oh, that, it worked on my computer,

I think I had to incldue

#include<algorithm>

for the header file.

But still, the judge gives me Wrong Answer after I put it on
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

I think you missed something... :D

Check the I/O..

Input:

Code: Select all

2C 3C 4C 5C 6C 7C 8C 9C 7D 8D
2C 3C 4C 5C 6C 7C 8C TC 7D 8D
2C 3C 4C 5C 6C 7C 8C JC 7D 8D
2C 3C 4C 5C 6C 7C 8C QC 7D 8D
2C 3C 4C 5C 6C 7C 8C KC 7D 8D
2C 3C 4C 5C 6C 7C 8C AC 7D 8D
2C 3C 4C 5C 6C 7C 8C 2D 7D 8D
2C 3C 4C 5C 6C 7C 8C 3D 7D 8D
2C 3C 4C 5C 6C 7C 8C 4D 7D 8D
2C 3C 4C 5C 6C 7C 8C 5D 7D 8D
2C 3C 4C 5C 6C 7C 8C 6D 7D 8D
Output:

Code: Select all

Black wins.
Black wins.
Black wins.
Black wins.
Black wins.
Black wins.
Black wins.
Black wins.
Black wins.
Black wins.
Black wins.
Hope it helps...
Ami ekhono shopno dekhi...
HomePage
Post Reply

Return to “Volume 103 (10300-10399)”