Bruno and Beads

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 16M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Bruno is widely known to be extremely organized, and it follows suit that he even likes to organize tiny beads. Bruno has N beads aligned on his desk side by side, each of which is coloured red, yellow, or blue. Red beads are represented by the character R, yellow by Y, and blue by B. It is guaranteed that there are all 3 types of beads present. A sequence of beads is considered to be organized if all beads of the same colour are grouped in a single contiguous sequence. For example, the sequence BBBRRRYYR is unorganized, since the rightmost red bead is not grouped together with the rest of the red beads. Bruno, being too preoccupied with homework, asks you to write him a program to determine if his sequence of beads is organized.

Input Specification

The first line contains one integer, N. (3 \le N \le 1000)

The second line contains a single string of length N, representing the initial state of the beads.

Output Specification

Output one string, Organized if the sequence is organized, otherwise FIX YOUR BEADS!.

Sample Input


Sample Output



  • 2
    Kirito  commented on March 20, 2016, 9:29 p.m.

    That moment you realize the reason why nothing's working is because you're submitting to the wrong problem. i-i

  • -1
    Anix55  commented on Nov. 19, 2015, 8:38 p.m.

    are grouped in a single contiguous sequence. continuous perhaps?