Travel Pass codechef solution
Chef is going on a road trip and needs to apply for inter-district and inter-state travel e-passes. It takesminutes to fill each inter-district e-pass application and minutes for each inter-state e-pass application.
His journey is given to you as a binary stringof length where denotes crossing from one district to another district (which needs an inter-district e-pass), and a denotes crossing from one state to another (which needs an inter-state e-pass).
Find the total time Chef has to spend on filling the various forms.
- The first line of the input contains a single integer denoting the number of test cases. The description of test cases follows.
- Each test case contains two lines of input.
- First line contains three space separated integers and .
- Second line contains the string .
For each testcase, output in a single line the total time Chef has to spend on filling the various forms for his journey.
Subtask #1 (100 points): original constraints
Sample Input 1
3 2 1 2 00 2 1 1 01 4 2 1 1101
Sample Output 1
2 2 5
Test case: Chef needs total inter-district e-passes, and he will be filling them in total minutes.
Test case: Chef needs total inter-district e-pass and inter-state e-passes, and he will be filling them in total minutes.
Also read : Airline Restrictions codechef solution
Also read : Large Square solution codechef
Also read : Bus full of passengers solution codechef
Also read : Friend Groups In A Line solution codechef