시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 28 | 8 | 8 | 72.727% |
Frodo has entered the mines of Moria and encountered a series of gates. Each gate has written upon it an ancient riddle describing the state of a set of special rings which control that particular gate. By examining the riddle, Frodo can determine whether or not the gate can be opened, or if it is simply a death trap.
Riddles consist of multiple runes. A valid rune contains exactly 3 statements about 3 different rings. Each statement in a rune is either true or false, depending on the state (spinning or not spinning) of a specific ring in the set of rings controlling the gate. The riddle for a particular gate does not have to use all of the possible rings contained in the gate’s controlling set.
To open the gates, the hobbits must read the riddle, then, decide which of the rings to spin, and which of the rings to leave alone. Once they have the correct rings spinning, they say an incantation, and if the entire riddle for the gate is satisfied the gate will open. For the gate to open, every rune in the riddle must have at least one statement in it that is true.
For example, consider a specific rune: 1 -2 3 0. This rune will be true if (ring 1 is spinning) OR (ring 2 is NOT spinning) OR (ring 3 is spinning). (NOTE: The 0 indicates the end of a rune, and at least one of the statements in that rune must be true for that specific rune to be true.) If a ring number in a rune is negative (e.g., -2), it means that ring 2 must NOT be spinning for that particular statement in the rune to be true. If the ring number is positive, (e.g., 3) it means that ring 3 MUST be spinning for that statement in the rune to be true. A specific ring may only appear one time in a specific rune, however, a ring may be used multiple times in the entire riddle, just not in the same rune!
The input will consist of the following:
Each gate contains exactly one riddle (consisting of multiple runes), and your algorithm should output exactly one line for each gate. If one or more runes in a riddle contain errors, output only the highest priority error for that riddle. The priority of errors is described below:
5 3 5 1 2 3 0 1 -2 3 0 1 3 -2 0 -3 -1 2 0 1 2 3 0 3 8 3 1 2 0 3 -1 2 0 3 1 -2 0 3 -1 -2 0 2 1 -3 0 -2 1 -3 0 -1 2 -3 0 -1 -2 -3 0 3 2 -1 1 3 0 0 1 3 0 3 2 -1 1 3 0 7 1 3 0 3 2 -1 1 3 0 2 1 3 0
RUNES SATISFIED! RUNES UNSATISFIABLE! TRY ANOTHER GATE! INVALID: NULL RING INVALID: RING MISSING INVALID: RUNE CONTAINS A REPEATED RING