Confusion about the logic


  • 2
    F

    I just wonder why the output of "DRRDRDRDRDDRDRDR" is R?
    As my understanding, the sequence processing (each senator comes in) as:
    D, D, R, D, R, D, R, D, R, D, DD, DD, DDD, DDD, DDDD, DDDD? where am i wrong. Thanks.


  • 3
    D

    You can always ban the closest senator from other party after you (to prevent him banning your teamates), so the sequence should be, "DRRDRDRDRDDRDRDR", "DRRRRDDD", "DRRR", mind that in the last run, the second R is banned by the first D, who is then banned by the third R.

    Other orders may also be acceptable, so long as there are enemies, you ban him.

    Correct me if I am wrong, and also, I do not understand your sequence processing order.


  • 0
    R

    Had the same thought process, and indeed, you can ban any other senator of your choosing, but the problem specifies that every senator will make the best decision, and voting someone that hasn't voted yet is a better choice than one who has already voted.

    This is why in this case, the second R senator will eliminate the next D senator, rather than banning the first D senator. as it will change the game around and make the Radiant team win.


  • 0
    F

    @dan_chow Thank u very much! I considered wise actions as always ban first person of another party to make persons in own party has high rank in next round...lol


  • 0
    J

    @fate1007 @dan_chow

    What about the case DRRD.
    D blocks first R
    so we had DRRD
    Then R should block first D to get DRRD

    With this R wins now not D.


  • 0
    D

    @JustDoIt Sorry, but the first run has not finished yet, the last D can block the second R and so only the last D survived the first run. Actually, it makes no difference which D to block in the first run, except that if it blocked the second D, it will survive until the second run.


  • 0
    J

    Thanks @dan_chow


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.