-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME
More file actions
73 lines (52 loc) · 3.04 KB
/
Copy pathREADME
File metadata and controls
73 lines (52 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
[Intro]=========================================================================
Chess is a very popular game played by hundreds of millions of people. Nowadays,
we have chess engines such as Stockfish and Komodo to help us analyze games.
These engines are very powerful pieces of well-developed software that use
intelligent ideas and algorithms to analyze positions and sequences of moves, as
well as find tactical ideas. Consider the following simplified version of chess:
- Board: It's played on a 4x4 board between two players named Black and White.
- Pieces and Movement:
- White initially has w pieces and Black initially has b pieces.
- There are no Kings and no Pawns on the board. Each player has exactly one
Queen, at most two Rooks, and at most two minor pieces (i.e., a Bishop
and/or Knight).
- Each piece's possible moves are the same as in classical chess, and each
move made by any player counts as a single move.
- There is no draw when positions are repeated as there is in classical chess.
- Objective: The goal of the game is to capture the opponent’s Queen without
losing your own.
Given m and the layout of pieces for g games of simplified chess, implement a
very basic (in comparison to the real ones) engine for our simplified version of
chess with the ability to determine whether or not White can win in less or
equal than m moves (regardless of how Black plays) if White always moves first.
For each game, print YES on a new line if White can win under the specified
conditions; otherwise, print NO.
[Input Format]==================================================================
The first line contains a single integer, g, denoting the number of simplified
chess games. The subsequent lines define each game in the following format:
- The first line contains three space-separated integers denoting the respective
values of w (the number of White pieces), b (the number of Black pieces), and
m (the maximum number of moves we want to know if White can win in).
- The w + b subsequent lines describe each chesspiece in the format [t c r],
where t is a character denoting the type of piece (where Q is Queen, N is
Knight, B is Bishop, and R is Rook), and c and r denote the respective column
(A, B, C, D) and row (1, 2, 3, 4) on the board where the figure is placed.
These inputs are given as follows:
- Each of the w subsequent lines denotes the type and location of a White
piece on the board.
- Each of the b subsequent lines denotes the type and location of a Black
piece on the board.
[Constraints]===================================================================
Each player initially has exactly one Queen.
[Output Format]=================================================================
For each of the g games of simplified chess, print whether or not White can win
in m moves on a new line. If it's possible, print YES; otherwise, print NO.
[Example]=======================================================================
Sample Input:
1
2 1 1
N B 2
Q B 1
Q A 4
Sample Output:
YES