CF A and B and Chess

A and B and Chess
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

A and B are preparing themselves for programming contests.

To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger.

For each chess piece we know its weight:

  • the queen's weight is 9,
  • the rook's weight is 5,
  • the bishop's weight is 3,
  • the knight's weight is 3,
  • the pawn's weight is 1,
  • the king's weight isn't considered in evaluating position.

The player's weight equals to the sum of weights of all his pieces on the board.

As A doesn't like counting, he asked you to help him determine which player has the larger position weight.

Input

The input contains eight lines, eight characters each — the board's description.

The white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters.

The white pieces are denoted as follows: the queen is represented is 'Q', the rook — as 'R', the bishop — as'B', the knight — as 'N', the pawn — as 'P', the king — as 'K'.

The black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k', respectively.

An empty square of the board is marked as '.' (a dot).

It is not guaranteed that the given chess position can be achieved in a real game. Specifically, there can be an arbitrary (possibly zero) number pieces of each type, the king may be under attack and so on.

Output

Print "White" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print "Black" if the weight of the black pieces is more than the weight of the white pieces and print "Draw" if the weights of the white and black pieces are equal.

Sample test(s)
input
...QK...
........
........
........
........
........
........
...rk...
output
White
input
rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR
output
Draw
input
rppppppr
...k....
........
........
........
........
K...Q...
........
output
Black

水题。。。MAP第一发
 #include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cctype>
#include <queue>
#include <map>
using namespace std; const int SIZE = ;
char MAP[SIZE][SIZE];
int main(void)
{
map<char,int> white;
map<char,int> black;
white['Q'] = ;
white['R'] = ;
white['B'] = ;
white['N'] = ;
white['P'] = ;
white['K'] = ; black['q'] = ;
black['r'] = ;
black['b'] = ;
black['n'] = ;
black['p'] = ;
white['k'] = ; int sum_w,sum_b;
char ch;
sum_w = sum_b = ;
for(int i = ;i < ;i ++)
for(int j = ;j < ;j ++)
{
scanf(" %c",&ch);
if(islower(ch))
sum_b += black[ch];
else if(isupper(ch))
sum_w += white[ch];
}
if(sum_w > sum_b)
puts("White");
else if(sum_w < sum_b)
puts("Black");
else
puts("Draw"); return ;
}
上一篇:Android ActionBar应用实战,高仿微信主界面的设计


下一篇:hibernate ORM related