Getting WA in STRQ.Why?

Getting WA in STRQ Problem - CodeChef

My code : CodeChef: Practical coding for everyone

Cant understand why WA.

Please help. Thanks in advance :slight_smile:

You may try this case-

cchheeffchef

3

c h 1 1

c h 2 3

c h 4 5

for c h 2 3 your code should print 1, but it prints 2

1 Like

Again WA :stuck_out_tongue:
http://www.codechef.com/viewsolution/7023231

Help please

You may try this case now -

chefchefcchheeff

4

c h 1 2

c h 1 5

c f 1 10

c f 1 3

for c f 1 10 you are getting wrong answer , try it !

Since u are getting TLE for subtask 2 you may try mine brute force approach as i am also not good in Dp.
What I did is for eg. this case c f 1 10 , traverse from 1 to 10 and if you encounter character as ā€˜cā€™ then increment count of c and whenever u encounter ā€˜fā€™ increment count of cf as cf=cf+c because count of strings starting with c and ending at f will depend on count of ā€˜cā€™ always, hope u understand.
My Solution - http://www.codechef.com/viewsolution/6202702

1 Like

yes,your code is nice.But why my code is not working?
Strange!!

You are now missing a very basic case


cf

2

f c 1 2

h f 1 2

for h f 1 2 your code gives output in my system as 33 which is wrong, either their is problem in initialization of your variables.