Chef and Cook-Off Contests
All submissions for this problem are available.
Read problems statements in mandarin chinese, russian and vietnamese as well.
Chef wants to prepare a Cook-Off contest with 5 problems chosen from a set of N problems. He has marked the difficulty of each problem within a range identified by one of the following strings: "cakewalk", "simple", "easy", "easy-medium", "medium", "medium-hard", "hard". According to this page, a Cook-Off contest must have problems of the following difficulties:
- exactly one "cakewalk";
- exactly one "simple";
- exactly one "easy";
- one "easy-medium" or one "medium";
- one "medium-hard" or one "hard".
Given the information about the N problems, can you advise Chef if it's possible to pick 5 problems and form a valid Cook-Off contest?
- The first line of input contains one integer T denoting the number of test cases.
- T test cases follow.
- The first line of each test case contains a single integer N.
- Then N lines follow; the i-th line contains a single string si, denoting the difficulty of the i-th problem.
For each test case, output "Yes" if it's possible to pick 5 problems and form a valid Cook-Off contest; otherwise, output "No".
- 1 ≤ T ≤ 100000
- 5 ≤ N ≤ 100000
- sum of N in all test cases ≤ 600000
- si can only be one of the following strings:
Subtask #1 (11 points):
- N = 5
Subtask #2 (27 points):
- 5 ≤ N ≤ 15
- T ≤ 100
Subtask #3 (62 points):
- original constraints
Input: 3 5 easy medium medium-hard simple cakewalk 7 simple simple medium medium easy-medium cakewalk easy 7 cakewalk simple easy easy-medium medium medium-hard hard Output: Yes No Yes
Example case 2: There are neither problems of "medium-hard" level nor "hard" level, so it's impossible to form a Cook-Off contest.
|Tags||cakewalk, ltime52, r_64|
|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, rust, SCALA, swift, 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, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.