시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
3 초 | 256 MB | 2 | 0 | 0 | 0.000% |
You’re assigned the job of making a booking system for a special services company. This company conducts all sorts of services, but you are told not to ask any questions. There have been some developers before you that have tried making this system, but sadly none of them are anywhere to be found, so you can’t ask them for any help.
The system is receiving bookings (and cancellations) one by one, and must immediately accept/reject the booking. All bookings last for a whole day, and the part of the system you’re making needs to keep track of a single day.
The company has a number of employees, each having one or more qualifications. Each booking, in addition to having been a given numeric identifier, demands a number of people (employees), each having a specific qualification. One person can cover at most one demand from one booking during the whole day. The director used Mario as an example; while Mario can be both a plumber and an assassin, in a single day he can only do one of the jobs for one booking (in this company).
A booking is accepted if and only if
A cancellation is accepted if and only if
The first line contains T, the number of test cases that follow. Each test case starts with a line containing the numbers N and B, the number of employees and bookings/cancellations in the test case.
Then there follow N lines, each specifying an employee. Each line consists of a number, c, followed by c strings delimited by whitespace, giving the names of each qualification of that particular employee.
Subsequently there follows B lines, each containing either a booking or a cancellation. A booking starts with the word book
. Then follows the numeric identifier I of that booking, followed by the number d and then finally d strings delimited by whitespace. This gives all qualification demands this booking has. A cancellation consists of a the word cancel
followed by a number referring to the identifier I of the booking to be cancelled.
BufferedReader
for input reading (not Scanner
).For each booking/cancellation, output a single line of output. The line should consist of the word Accepted
if the booking/cancellation is accepted, or Rejected
otherwise.
2 1 1 1 slacker book 6 1 worker 3 6 2 plumber nurse 2 nurse assassin 2 assassin plumber cancel 1 book 1 2 plumber assassin book 123 1 nurse book 4 3 assassin nurse plumber cancel 1 book 4 2 nurse assassin
Rejected Rejected Accepted Accepted Rejected Accepted Accepted
Contest > IDI Open Contest > IDI Open 2013 C번