#P14872. [ICPC 2020 Yokohama R] High-Tech Detective
[ICPC 2020 Yokohama R] High-Tech Detective
题目描述
The problem set document for the Yokohama Chinatown Gluttony Contest was kept in a safe at the headquarters of the Kanagawa Gourmendies Foundation. It was considered to be quite secure, but, in the morning of the very day of the contest, the executive director of the foundation found that the document was missing!
The director checked that the document was in the safe when she left the headquarters in the evening of the day before. To open the door of the headquarters office, a valid ID card has to be touched on the reader inside or outside of the door. As the door and its lock are not broken, the thief should have used a valid ID card.
Normally, all the entries and exits through the door are recorded with the ID. The system, however, has been compromised somehow, and some of the recorded ID’s are lost.
It is sure that nobody was in the office when the director left, but, many persons visited the office since then to prepare the contest materials. It is sure that the same ID card was used only once for entry and then once for exit.
The director is planning inquiries to grasp all the visits during the night. You are asked to write a program that calculates the number of possible combinations of ID’s to fill the lost parts of the records.
输入格式
The input consists of a single test case of the following format.
$$\begin{aligned} &n\\ &c_1 \ x_1\\ &\vdots\\ &c_{2n} \ x_{2n}\\ \end{aligned}$$The first line contains an integer (), representing the number of visitors during the night. Each visitor has a unique ID numbered from to . The following lines provide (incomplete) entry and exit records in chronological order. The -th line () contains a character and an integer (). Here, and indicate some visitor entered and exited the office, respectively. denotes the visitor ID, where indicates the ID of the visitor is , and indicates the ID is lost. At least one of them is . It is guaranteed that there is at least one consistent way to fill the lost ID(s) in the records.
输出格式
Output a single integer in a line which is the number of the consistent ways to fill the lost ID(s) modulo .
4
I 1
I 0
O 0
I 0
O 2
I 4
O 0
O 4
3
3
I 0
I 0
I 0
O 0
O 0
O 0
36