Mafia
Time limit1sMemory limit1024 MB
Given accusations of honesty or corruption between cops, count for each queried C the number of size-C corrupt sets consistent with all accusations.
- Level
Hard8 of 10
- Topics
- Graph, Union-find, Combinatorics, Dynamic programming
- Solved
- No attempts yet
Problem
A mafia has infiltrated the city <insert name here>. This has left the police force of <insert name here> in deep confusion, with accusations of corruption coming from every direction. The city's cops (numbered from to ) have made a number of accusations about other policemen. Each accusation is one of the following:
- Police officer is an honest cop.
- Police officer is a corrupt cop.
An honest cop always tells the truth, while a corrupt cop always lies. In total there have been accusations.
The chief of police is now trying to fix the situation, starting by determining how many of her police officers are corrupt. She has different guesses about the number of corrupt cops, and for each such number she wants to know how many different sets of size can be corrupt (with all remaining cops honest), given that all accusations are consistent.
Input
The judge reads input in the following format:
- line :
N M - line :
A[0] ... A[M - 1] - line :
B[0] ... B[M - 1] - line :
T[0] ... T[M - 1] - line :
G, the number of calls made toguess(C). - line :
C1 ... CG, the parameters of the calls toguess(C).
Output
The judge writes lines containing the return values of guess(C).
Constraints
Let be the number of calls to guess(C).