Who Wants to Live Forever?
Time limit1sMemory limit128 MB
Decide whether a bit string evolving under the Rule 90 XOR-neighbor cellular automaton eventually becomes all zeros or oscillates forever.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Math, Simulation, Number theory
- Solved
- No attempts yet
Problem
Digital physics is a collection of ideas and hypotheses built around the notion of a computable universe. Perhaps our universe is just a large program running on a Turing machine? Is the state of the universe finite? Will the universe eventually end? For now we can only theorize.
To push the frontier of digital physics a little further, consider a specific toy model of the universe — we will call it Bitverse — and decide whether its life comes to an end or it keeps evolving forever.
Bitverse is a single row of bits, each either or . The universe comes into being as one particular row of bits — an event we call the Bit Bang — and from then on it evolves in discrete steps.
The rule is simple. To compute the next value of the -th bit, look at the current values of its neighbours at positions and (a neighbour that falls outside the row is treated as ). If exactly one of the two neighbours is , the next value of the -th bit is ; otherwise it is . Every bit is updated simultaneously, so the next state depends only on the previous state.
The universe is dead once it consists solely of zeros.
Given the state of Bitverse at the Bit Bang, answer the fundamental question: will Bitverse live forever, or will it eventually die?
Input
The first line contains the number of test cases .
Each of the following lines contains one test case: a string of between and characters, each either 0 or 1, describing the initial state of a Bitverse.
Output
For each test case print a single line: LIVES if that universe evolves forever, or DIES if it eventually becomes all zeros. Print the answers in the same order as the input.
Hint
The first sample universe never becomes all zeros; it keeps oscillating: 01 → 10 → 01 → … . The second one dies after a few steps: 0010100 → 0100010 → 1010101 → 0000000. The third one is a fixed point and never changes.