Page 1 of 2

Posted: Sun Jan 06, 2002 9:25 am
by ChrisIzquierdo
Can someone please give me a set of inputs/outputs for this problem? I wrote a program that I think should solve this problem but the online judge replied a wrong answer to my post.

Are there any tricks I should be aware?

Thanks.

Posted: Mon Jan 07, 2002 7:59 am
by ChrisIzquierdo
I forgot to mention that I'm using Java to solve this problem.

I downloaded from the web a C program that solves this problem (acknowledge by the online judge) and using extensive test cases both my Java program and this C program give the same results.

I think that the difference might be on the way input is passed to the program once is compiled by the online judge. (That's the disadvantage of using Java to solve these problems - well other than speed).

Any thoughts on this?

This problem seemed so simple...

Thank you very much for any help

170 - Clock Patience

Posted: Fri Feb 21, 2003 10:11 pm
by ileti
I know this is classic problem but i really have solve 170th problem but judge said to "wrong answer" .
? doubt from this sentence "The output will consist of one line per deck "
if there is one output , after the solution ,consist a '\n' or not or , there are multiple output , after last one , become a new line character '\n' or not or any other probability. Please help me [/c]

Posted: Sat Feb 22, 2003 5:42 am
by turuthok
My AC-ed solution gave this kind of output:

44,KD
01,2S

So, it is really one output line per deck.

Before I submitted a solution I had this error when I didn't clear up some variables in one case, thus, it fails the next case ... not sure if you have the same problem as I did. I'm sure you tested more than one case ...

-turuthok-

Posted: Sat Feb 22, 2003 7:44 pm
by ileti
I edit my code with your suggestion , yes i had been a wrong about second ,third and other inputs , forget initilaze some variable . but i can't accepted to judge :cry: Yes i try more than one input , but don't do. Do you have other inputs please send to me
thanks

Posted: Sat Feb 22, 2003 11:11 pm
by turuthok
Honestly, I can't think of any trick of this problem. It's plainly straightforward ... it must be just a minor thing that you overlooked in your code.

Good luck,

-turuthok-

170 Clock Patience

Posted: Fri May 09, 2003 5:00 pm
by titid_gede
i want to ask, whether i misunderstood the problem or not. i've simulated the sample input, i got 51,KC, instead of 44,KD.
here is my code
[c]
#include <stdio.h>
#include <string.h>
#include <ctype.h>

typedef struct {
char angka, bentuk;
} tcard;

tcard stack[13][4], opencard;
int top[13], jumopen;

int convert (char x) {
int ret;

if (x >= '2' && x <= '9')
ret = x-'0'- 1;
else {
switch (x) {
case 'A' : ret = 0; break;
case 'T' : ret = 9; break;
case 'J' : ret = 10; break;
case 'Q' : ret = 11; break;
case 'K' : ret = 12; break;
}
}
return ret;
}

int main() {
char ch;
int jum, l, i;

while (1) {
ch = getchar();
while (!isalnum (ch) && ch != '#') ch = getchar();
if (ch == '#') break;
memset (top, 0, sizeof(int)*13);
jum = 0;
while (1) {
if (jum == 52) break;
if (isalnum (ch)) {
stack[jum%13][top[jum%13]].angka = ch;
ch = getchar();
stack[jum%13][top[jum%13]].bentuk = ch;
top[jum%13] = top[jum%13] + 1;
jum++;
}
ch = getchar();
}

opencard = stack[12][3]; top[12] = top[12] - 1;
l = convert (opencard.angka);
while (top[l] != 0) {
top[l] = top[l] - 1;
opencard = stack[l][top[l]];
l = convert (opencard.angka);
}
jumopen = 52;
for (i = 0; i < 13; i++)
jumopen -= top;
printf ("%2d,%c%c\n", jumopen, opencard.angka, opencard.bentuk);
}
return 0;
}
[/c]

Posted: Fri May 09, 2003 10:48 pm
by turuthok
Hello titid, ... 51,KC seems very familiar to me ... it's all about this input description (especially the last sentence):
The input will consist of decks of cards arranged in four lines of 13 cards, cards separated by a single blank. Each card is represented by two characters, the first is the rank (A, 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K) followed by the suit (H, D, C, S). The input will be terminated by a line consisting of a single #. The deck is listed from bottom to top, so the first card dealt is the last card listed.
-turuthok-

Posted: Sat May 10, 2003 4:11 pm
by titid_gede
i dont understand for what you mean. oke to make it simpler for me. what is the first card deal for sample input? 3C?

Posted: Sat May 10, 2003 4:17 pm
by turuthok
Yes.

-turuthok-

Posted: Sat May 10, 2003 4:31 pm
by titid_gede
here are cards open when playing game for given sample input

Code: Select all

3C
AH
AS
6D
JC
QD
6C
JS
4C
6H
QS
6S
2D
7C
7D
8H
AC
9D
5C
KD
9C
8C
3D
9S
4H
5S
7S
TD
TC
3S
7H
3H
8S
2C
4S
JD
AD
TS
5H
2S
JH
TH
2H
QC
4D
8D
KH
5D
QH
KS
KC
now i can see that the last card is KC, not KD as in given sample output. am i wrong?

Posted: Sat May 17, 2003 10:36 am
by Red Scorpion
No, the output for sample input in problem is KD, not KC.
:lol:

Posted: Tue Jun 24, 2003 5:43 am
by Observer
Plz note what "dealt" mean...... :lol: :lol: :lol:

Posted: Tue Oct 07, 2003 6:25 pm
by szymcio2001
For everybody who don't know yet how to read input:
You should start playing with "TS"

Problem 170 TLE

Posted: Sat Apr 24, 2004 5:25 am
by chunyi81
I tried to solve problem 170 clock patience, and I have tested with 4 decks of cards in a single input file. My program gave the outputs for the 4 decks of cards fast. Is there any sample input that I could test with to find out why time limit exceeded? And how many decks of cards could there be in a single input file? I have also tested with a test case that actually plays out the whole deck and it works as well. What could be wrong? Can anyone help please?

Here is the sample input I tested with:

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

And the outputs:

44,KD
04,KD
51,KC
52,KD