## 162 - Beggar My Neighbour

Moderator: Board moderators

wyvmak
Experienced poster
Posts: 110
Joined: Thu Dec 13, 2001 2:00 am
pls help. i think i don't understand how it works.

say 52 cards, input: c1,c2... c52
then non-dealer gets c51, c49, ... c1.
and dealer gets c52, c50, ... c2.
then non-dealer starts with c51, dealer starts to play with c52. so on.

let's do it by example (simplified):
non-dealer (3 cards): 2 J 2 3
dealer (3 cards): 2 3 4 5
so 2->2->J, then dealer needs to cover by 3.
so will become
non-dealer: 2 3
dealer: 4 5 2 2 J 3,
is it? and the dealer next plays 4?

that's my interpretation, and i don't know why i can't even product the sample output "1 44" from the sample input.

Even
Learning poster
Posts: 75
Joined: Thu Nov 22, 2001 2:00 am
Location: Taiwan

no-dealer : 2 Q 4 3...
dealer : 3 K 5 2 ...

then begin ...

2 -> 3 -> Q ...and now dealer should put 2 cards...
but when dealer put one card...we find it is "K"...
then dealer need not put the second card...
and no-dealer then should put three cards....

till any player has no cards to put...
and the other will win the game...

wyvmak
Experienced poster
Posts: 110
Joined: Thu Dec 13, 2001 2:00 am
i understand that. it'll be reversed when 'K' is put. but still cannot work out the sample. so what else is missing?

Even
Learning poster
Posts: 75
Joined: Thu Nov 22, 2001 2:00 am
Location: Taiwan

if ...

non-dealer 2 J 2 3
dealer 2 3 2 4

than 2-> 2-> J ...then dealer cover by 3 ..
and then "non-dealer" take the heap...

non-dealer 2 3 2 2 J 3
dealer 2 4

then non-dealer put 2 ...

wyvmak
Experienced poster
Posts: 110
Joined: Thu Dec 13, 2001 2:00 am
oh dear, poor my english and understanding, thanks a thousand

Aggag
New poster
Posts: 1
Joined: Sat Aug 31, 2002 10:52 pm
Contact:

### 162 Sample Inputs

Does anyone have some sample inputs for the "Beggar My Neighbour" problem (162). I have got the provided sample input right but still get WA from the judge over and over again. Its may be that i am missing something that isnt included in the sample input. Thanx alot in advance.
Khalid Aggag

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong
Hello!!!!

Plz anyone plz help!!! I'm getting WA!!!!
My code can pass the sample input, and I can't think of any cases that make it fail......

Plz could someone give me some test cases??? Thx in advance!!!!

(Hope someone can give me a reply)

By the way, what should be the output for the following case?
H3 H3 H3 H3 H3 H3 H3 H3 H3 H3 H3 H3 H3
H3 H3 H3 H3 H3 H3 H3 H3 H3 H3 H3 H3 H3
H3 H3 H3 H3 H3 H3 H3 H3 H3 H3 H3 H3 H3
H3 H3 H3 H3 H3 H3 H3 H3 H3 H3 H3 H3 H3
#
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong
FInally got an ACC!!! I've made a very very minor glitch......

Btw, the output for the case above is '1 0'.

P.S. My program fails in cases like this:
DQ H2 H4 D4 D5 HK D3 D4 H3 D5 D7 S3 S2
D2 H2 H4 D3 D5 H6 D3 D4 H3 D5 D7 S3 S2
D2 H2 H4 D3 D5 H6 D3 D4 H3 D5 D7 S3 S2
D2 H2 H4 D3 D5 H6 D3 D4 H3 D5 D7 ST S2
#
The Output should be '2 51'......
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org

parmaia2000
New poster
Posts: 1
Joined: Wed Aug 13, 2003 4:27 am

Please, im looking for some test cases that can help me solve the problem, i test my code with all the cases listed here and i get the correct answer but i still get an WA.

PD. Sorry, my english is not the best, but i do what i can!!!

Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

### 162 - Beggar My Neighbour

I can't understand why I get WA. Are there any special cases I should care for? Any sample tests? Which input format is correct:

A)
HA H3 H4 CA SK S5 C5 S6 C4 D5 H7 HJ HQ
D4 D7 SJ DT H6 S9 CT HK C8 C9 D6 CJ C6
S8 D8 C2 S2 S3 C7 H5 DJ S4 DQ DK D9 D3
H9 DA SA CK CQ C3 HT SQ H8 S7 ST H2 D2
HA H3 H4 CA SK S5 C5 S6 C4 D5 H7 HJ HQ
D4 D7 SJ DT H6 S9 CT HK C8 C9 D6 CJ C6
S8 D8 C2 S2 S3 C7 H5 DJ S4 DQ DK D9 D3
H9 DA SA CK CQ C3 HT SQ H8 S7 ST H2 D2
#

B)
HA H3 H4 CA SK S5 C5 S6 C4 D5 H7 HJ HQ
D4 D7 SJ DT H6 S9 CT HK C8 C9 D6 CJ C6
S8 D8 C2 S2 S3 C7 H5 DJ S4 DQ DK D9 D3
H9 DA SA CK CQ C3 HT SQ H8 S7 ST H2 D2

HA H3 H4 CA SK S5 C5 S6 C4 D5 H7 HJ HQ
D4 D7 SJ DT H6 S9 CT HK C8 C9 D6 CJ C6
S8 D8 C2 S2 S3 C7 H5 DJ S4 DQ DK D9 D3
H9 DA SA CK CQ C3 HT SQ H8 S7 ST H2 D2
#

Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:
It came out that I misunderstood the problem. A player looses not when he has no cards, but when he has no cards _and_ he has to make a move.

Experienced poster
Posts: 131
Joined: Thu Apr 17, 2003 8:39 am
Location: Baku, Azerbaijan

### 162 Beggar My Neighbour

Hi. Need some %100 I/O to test my program.
_____________
NO sigNature

El-idioto
New poster
Posts: 45
Joined: Mon Jul 14, 2003 9:42 pm
Location: Zoetermeer, The Netherlands
My TLE app can solve about 250000 inputs in 10 seconds on my Athlon 2200. I can scarcely believe my app is too slow.
Unfortunately, it is possible to have a cycle in the game. One such a cycle is:

Code: Select all

ST S8 C6 C6 ST HT D6 D6 DK H2 D6 D5 D2
H3 C8 H8 D5 H3 HT CJ S5 D2 H7 H7 SK ST
D3 D9 H3 S9 C3 CT C6 S8 S7 H5 H5 S3 ST
C7 H2 H2 D6 D5 H5 D8 C8 C5 D4 H3 S8 D9
#
Can someone with an AC app tell me whether their app gives a result?

Also, can someone with an AC app send me their (Windows) exe so I can test against my app?

danielrocha
New poster
Posts: 44
Joined: Sun Apr 27, 2003 3:17 am
Location: Rio Grande do Norte - Brazil
Contact:

### Infine loops

I don't think you should really worry about that input. I ran it on my AC program and it also locked (circular loop). There were two inputs that I tried before getting the program accepted:

Code: Select all

H9 DA SA CK CQ C3 HT SQ H8 S7 ST H2 D2
S8 D8 C2 S2 S3 C7 H5 DJ S4 DQ DK D9 D3
D4 D7 SJ DT H6 S9 CT HK C8 C9 D6 CJ C6
HA H3 H4 CA SK S5 C5 S6 C4 D5 H7 HJ HQ

DA SA CK CQ C3 HT SQ H8 S7 ST H2 D2 DQ
S8 D8 C2 S2 S3 C7 H5 DJ S4 H9 DK D9 D3
D4 D7 SJ DT H6 S9 CT HK C8 C9 D6 CJ C6
HA H3 H4 CA SK S5 C5 S6 C4 D5 H7 HJ HQ

#
The output:

Code: Select all

1 51
1 41
Daniel
UFRN HDD-1
Brasil

shuniu
New poster
Posts: 34
Joined: Thu Oct 16, 2003 6:15 pm
I get WA for this prob, can somebody help me out by posting an AC output to the following input? Thanks!

Input (30 randomly generated test cases):

Code: Select all

S8 D8 HQ S6 HK C8 HT D4 H2 H7 SA D5 D3
CK H5 H4 C4 D6 S2 DA ST C6 D9 D2 DQ SQ
S4 DJ CA C2 H9 C5 HA DK CJ H3 S9 C3 HJ
SK CT CQ SJ C9 DT S7 S5 H8 S3 C7 D7 H6
C3 DQ CJ C6 SK DK S8 D2 CT HT DJ S9 S4
D6 S5 H2 HJ S2 S7 DA CK D4 ST CQ S6 C9
SQ D3 HA SA H4 C7 H5 H8 D8 H9 H6 D9 CA
DT H7 H3 HK C8 SJ C5 D7 C2 S3 D5 C4 HQ
CK D7 C9 D2 HQ HT SA D6 DT C5 CT S3 HK
S4 C2 C7 HJ D9 CQ H7 H5 CA DQ SK S6 S8
C3 H3 C4 C6 H6 DK H9 HA D4 CJ H8 S5 DJ
SQ S7 DA ST D8 S2 D3 S9 D5 SJ H2 H4 C8
H9 S7 HQ H6 C8 DA H3 SJ DQ ST H5 H7 C7
H4 HA D5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