#P3883. [JLOI2008] 棋局定式
[JLOI2008] 棋局定式
Description
In the "jloi-08" game, there are a large number of standard sequences, that is, commonly used combinations of moves. Sometimes, when studying a famous game, the computer will quiz Mr. Liu: How many standard sequences are in this game? What are they?
For ordinary games with to moves, Mr. Liu can still answer. But sometimes, in a game between two equally strong players, there may be as many as moves. If the computer asks the above questions about such a game, Mr. Liu must write a program to help himself. However, Mr. Liu is not good at this... He keeps getting it wrong. Can you help him?
A game consists of many steps, and a step is represented by a string, such as Kh2 or Nxb7.
The former means K (king) moves to h2, and the latter means N (knight) moves to b7 and captures the piece there.
The first character can be one of 6 types: K Q B N R P, and the rest is either a coordinate or the character x followed by a coordinate.
A coordinate consists of a lowercase letter from a to h and a digit from 1 to 8.
If a game contains all the steps of a standard sequence completely and consecutively, then the game contains that standard sequence.
Input Format
The first line contains two integers , representing the number of standard sequences () and the number of steps in the game.
Then follow blocks; each block contains:
- The first line contains an integer , the number of steps in the standard sequence (, ).
- The second line contains a string, the name of the standard sequence (length no more than ).
- Each of the next lines contains one string, representing one step in the standard sequence.
Each of the last lines contains one string, representing one step in the game.
Output Format
In the order of the input, output the names of all standard sequences contained in the game, one per line.
2 5
3
King's Knight Opening
Pe4
Pe5
Nf3
3
Nimzowitsch Variation
Pc4
Pe5
Nf3
Pe4
Pe5
Nf3
Nc6
Bb5
King's Knight Opening
Hint
It is not guaranteed that the given game and standard sequences comply with the rules of chess.
Translated by ChatGPT 5
京公网安备 11011102002149号