Giovanni And Secret Message
All submissions for this problem are available.
Giovanni is given a secret message from a fortune-teller. The fortune-teller says that if in the message there exist exactly 3 dashes between every pair of numbers that add up to 11 then Giovanni will win the lottery otherwise not.
Giovanni is bad at pattern recognition so he asks you to tell his fortune. Write a program to decide whether Giovanni wins the lottery or not.
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
- The first each test case contains a string
- print "YES" if Giovanni wins the lottery else "NO" ,without quotes
- 1 ≤ T ≤ 102
- 0 ≤ Length of string ≤ 103
Input: 3 atrb5---6xyul2---eke7 abc-4--sss-7lr-1 ab5--7-6-6yuptr Output: YES YES NO
In case 1 one pair (5, 6) adding up to 11 exists and there are 3 dashes between them.
In case 2 one pair (4, 7) adding up to 11 exists and there are 3 dashes between them.
In case 3 there are two pair (5, 6) which adds to 11 but one doesn't have exactly 3 dashes
|Tags||easy-medium, hashing, ince2019, prajapat786, prajapat786, strings|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, 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, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.