Dr. Bill Poucher
Time limit2sMemory limit512 MB
Given a directed visibility graph on n people with black or white hats, decide whether a deterministic strategy guarantees at least one survivor.
- Level
Medium7 of 10
- Topics
- Graph, Game theory, Math, Implementation
- Solved
- No attempts yet
Problem
There are people. Each person sees some of the other people. Each of them will be given a black or white hat. After that each person will simultaneously name a color. Everyone who doesn't guess the color on his hat will die. Horribly.
Is there a deterministic strategy which guarantees that at least one person will survive?
Input
The first line contains two integers and (), the number of people and the number of relations of seeing someone (see below), respectively.
lines follow. -th of them contains two integers and () meaning that -th person sees -th person. For all , or holds.
Output
Print 1 if there exists such strategy and 0 otherwise.