After many years of working as a software developer you have decided to try something entirely difierent, and started looking at random job ofiers. The one that really caught your eye was a job in fish farming (a form of aquaculture). ’Cool!’, you thought, and besides, fish are nice creatures. So you applied, got accepted, and today is your first day at work.
Your boss has already assigned you a task. You have to isolate one water reservoir from another. After looking at some schemes you’ve been given, here’s what you’ve figured out.
The two water reservoirs are connected by several channels. Each channel has two gates. The channel is open when both gates are open, and is closed otherwise. The gates are controlled using switches. The same switch may operate several gates, but each gate is operated by exactly one switch. It is possible that both gates on a channel are controlled by the same switch and that a switch controls no gates.
The switch may operate the gate in one of two ways:
Write a program that, given the configuration of gates and switches, determines whether it is possible to close all channels, and if it is, then finds a state of every switch in one such valid configuration.
If it is impossible to close all channels, your program should output one line, containing a single word IMPOSSIBLE.
입력 3 2 1 0 2 1 1 0 2 0 1 1 2 1 출력 0 1 입력 2 1 1 0 1 0 1 1 1 1 출력 IMPOSSIBLE The first example corresponds to the picture from the task description
출처:BOI 2008 day1 3/7