Problem Statement:
You are exploring a hazardous chamber filled with ion particles arranged in a line. Each particle i has an intensity I[i].
Whenever you decide to activate particle i, it releases an ion trail of magnitude:
trail_i = I[i] % (i + 3)
This trail interferes with future particles. After choosing particle i, any later particle j > i becomes unstable (and therefore cannot be selected) if:
((I[j] xor I[i]) % 6) == trail_i
Your goal is to select as many stable particles as possible, in strictly increasing index order. You may choose or skip any particle, but once a particle becomes unstable, it cannot be chosen later.
Find the maximum number of particles you can select while respecting instability rules.
Input Format:
Problem Statement:
You are an explorer of the Aurora Vaults, facing a line of spectral nodes numbered from 1 to N. Each node i glows with a spectral value S[i].
Every time you include a node in your expedition log, it prints a single-colour key into the vault's ledger:
Key(i) = (S[i] + i) % 5
But the ledger is tricky: as soon as you record node i, all later nodes j (j > i) whose(S[j] % 5)equalsKey(i)become locked — you cannot record them later in your sequence. Nodes already recorded remain safe.
You may decide, at each position scanning left to right, whether to record that node or skip it. Your aim is to record a sequence of nodes (strictly increasing indices) of maximum possible length under the locking rule.
Find the maximum possible length under the locking rule.
Input Format: