Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Save Abul Bhai!

By Minhaj_10 · Limits 1s, 512 MB

In a parallel universe North African nation of the Republic of Wadiya has been ruled by Admiral-General Haffaz Aladeen. The Dictator Aladeen build a video game called ‘Dead-land'. Aladeen forces one of his employee named ‘Abul Bhai’ to become first experimental user of the game.

In this game if ‘Abul Bhai’ win PP number of matches consecutively Aladeen will punish him for hacking the game and if ‘Abul Bhai’ lose QQ number of matches consecutively again he will be punished by Aladeen for being a loser. If ‘Abul Bhai’ is able to skip both cases he is safe.

Determine whether ‘Abul Bhai’ is safe or not.

Input

The first line of input contains three integers N(1N2×105)N \hspace{.1cm} (1 \leq N \leq 2×10^5 ), P(1P105)P \hspace{.1cm} (1 \leq P \leq 10^5) & Q(1Q105)Q \hspace{.1cm} (1 \leq Q \leq 10^5).
NN represents the number of matches Abul Bhai played.

The second line of input contains a string SS consisting of NN characters where each character contains ‘00’ or ‘11’. Here, ‘00’ represents that he lost the match and ‘11’ represents he won the match.

Output

If he is safe print “Abul Bhai is safe” else print “Abul Bhai is in danger”.

Sample

InputOutput
10 5 3                                                 
1010101010 
Abul Bhai is safe

    Discussion

    Statistics


    89% Solution Ratio

    aritra741Earliest, Oct '20

    aritra741Fastest, 0.0s

    EgorKulikovLightest, 0 B

    bokaifShortest, 118B

    Submit

    Login to submit

    Editorial

    Here you have to count the maximum number of consecutive zero and one. Suppose a is the maximum cons...

    Toph uses cookies. By continuing you agree to our Cookie Policy.