This page is still under construction.

Parts of this page are still being built. What you see may change.

Coins

Time limit2sMemory limit512 MB

Summary
Maintain the probability that the number of heads among N coins is odd, under M point updates to individual coin probabilities, and report which outcome is more likely after each update.
Level

Medium7 of 10

Topics
Math, Probability, Dynamic programming, Implementation
Solved
No attempts yet

Problem

There are NN coins with possibly different heads probabilities. Toss all NN coins. You survive when the number of heads is odd, and you die when it is even.

An initial state is given, followed by MM updates. Each update specifies a coin index and its new heads probability. Compare the survival probability against the death probability in each of the M+1M+1 states, from the initial state with 00 updates to the final state with MM updates.

Input

The first line contains NN and MM, where 1≤N≤5000001 \le N \le 500000 and 0≤M≤5000000 \le M \le 500000. The second line contains NN real numbers. The ii-th number is the heads probability of coin ii. Each of the following MM lines contains a coin index and its new probability.

Every probability is at least 00 and at most 11, written with up to 66 digits after the decimal point.

Output

Print M+1M+1 lines. Line ii holds the answer for the state after i−1i-1 updates.

Print "ALIVE" when survival is more likely and "DEAD" when death is more likely. Print "SAME" when the two probabilities are equal.

Hint

With heads probabilities 0.30.3, 0.40.4, and 0.70.7, survival has probability 0.5160.516 and death has probability 0.4840.484. Survival is more likely.

Examples2

  1. Example 1

    Input
    2 3
    1.000000 1.000000
    1 0.000000
    2 0.500000
    2 0.000000
    
    Expected output
    DEAD
    ALIVE
    SAME
    DEAD
    
  2. Example 2

    Input
    3 0
    0.300000 0.400000 0.700000
    
    Expected output
    ALIVE