All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian
You are given a string S constisting of uppercase Latin letters. Is it possible to reorder the characters in this string to get a string with prefix "LTIME" and suffix "EMITL"?
We remind you that a prefix of a string is any substring which contains its first character, while a suffix of a string is substring containing its last character.
The first line contains a single integer T, denoting the number of testcases. The descriptions of T test cases follow.
The first and only line of the test case description has one non-empty string S consisting of uppercase Latin letters only.
For each testcase output a single line containing the string "YES" (without quotes) if it's possible to reorder the characters to get the required prefix and suffix, or "NO" (without quotes) otherwise.
- Subtask 1 (23 points) : 1 ≤ T ≤ 100, 1 ≤ |S| ≤ 9
- Subtask 2 (77 points) : 1 ≤ T ≤ 1000, 1 ≤ |S| ≤ 100
Input: 3 LTIMEAZAZAITLME LLLTTTIIIMMMEEEAHA LTIMEM Output: YES YES NO
Test case 1: we can permute the last 5 letters and get LTIMEAZAZAEMITL
Test case 2: we have 3 copies of each of the letters 'L', 'T', 'I', 'M', 'E' so we can leave 5 of them in the beginning and move 5 of them to the end.
Test case 3: we have only one letter 'L' so we can't make necessary prefix and suffix at the same time.
|Tags||ad-hoc, cakewalk, implementation, ltime29, pavel1996, string|
|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.