Time

10:48:55
11 Feb 2012
ACM-ICPC Thailand Southern Region Programming Contest 2011
Left: 4 hours 12 minutes
End: 11.02.2012 15:00
Leader: Informatimukas
Five for week 22
Left: 11 hours 12 minutes
End: 11.02.2012 22:00
Leader: NuM
Version for print

Queen and pawn

prb32   On famous and popular site we have a problem “Elephant and pawn ” => http://acm.timus.ru.

   We propose to You a similar game, in which take place white pawn and black horse. Moves are made in accordance with the usual chess rules. Whites moves first. Whites wins, if they could transformation their pawn in queen and next move by black horse can’t destroy queen. The game is finish draw, if turn of moves for whitening, but pawn can’t move on. If the horse could beat the pawn or queen, than win blacks. You must elucidate a outcome (result) of game with the best playing from each others.


Specifications

   Input

   In one line through the gaps we have a start position of white pawn, and black horse (in chess notation, but without figure). 

   Output

   Make clear 1 – if will win whites, make clear -1 – if will win blacks and 0.5 – if the game will finish draw.


Problem information

Time Limit: 1 seconds
Memory Limit: 64 MB
Balls for the passed test: 0.694444
Complexity: 67% 21/64
Autor: awpris
Classes: Dynamic programming, Game strategies

Example

Example input

g3 a1

Example output

-1


← Superstitious Santa Claus Problems The favorite numbers of Santa Cl →