Game of Cards
All submissions for this problem are available.
Game of Cards
A contiguous string is a string in which all the occurrences of each character of the string is together (i.e. no same character should be separated by one
or more other characters). For example,
"dittoo" and "dit" are contiguous strings.
"techxetra" is not a contiguous string since the 't's don't occur together.
In Game of Cards, you are given a fixed number of cards, each card having a string. The cards with different strings can be combined to create new strings.
You have to combine the cards in such a way that the combined string formed will be contiguous. If more than one contiguous string can be formed you have
to say “MORE THAN ONE””, if a contiguous string cannot be formed from the given cards say "NOT POSSIBLE" (all quotes for clarity).
First line will contain the no. of test cases T.
Each test case contains two lines of input. The first line contains the no. of cards K. The second line contains K strings separated by a single
space, denoting the content of the cards.
If only one contiguous string can be formed print the string.
If many such strings can be formed print "MORE THAN ONE".
If no such contiguous string can be formed print "NOT POSSIBLE".
Each card will contain a string of length between 1 to 20 characters, inclusive.
Characters can only be lowercase letters (a-z).
zzzz zz z
ro a r
MORE THAN ONE
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.