Question: This should be done in C language!!! 1. All test cases are given and there are no code templates 2. There are solution analysis in



This should be done in C language!!!
1. All test cases are given and there are no code templates 2. There are solution analysis in the end. 3. There are run time limits 4. Every test set runs 100 cases, avoid allocating and freeing memory frequently, since it may cause memory allocation issue, especially test set2. Try to use the same memory for each test case. 5. You should make sure your code runs on the largest case, since if that runs correctly, the other cases would be fine in terms of memory issue. Problem Given an array of N positive integers. The i-th integer of the array is A_i. A contiguous subarray is an m-stopwatch if it is of length m and contains the integers m,m1,m2,,2,1 in that order. For example, 1] is a 3-stopwatch. Can you count the number of K-stopwatchs in the array? Input The first line of the input gives the number of test cases, T. T test cases follow. Each test case begins with a line containing the integers N and K. The second line contains N integers. The i-th integer is Ai. Output For each test case, output one line containing , where x is the test case number (starting from 1) and y is the number of K. stopwatchs in the array. Limits Time limit: 60 seconds. 1T100.2KN.1A2105,foralli. Test Set 1 2N1000. Test Set 2 2N2105 for at most 10 test cases. For the remaining cases, 2N1000. Sample In sample case \#1, there are two 3-stopwatchs as highlighted below. - 123798321 - 123793218 In sample case \#2, there are no 2-stopwatchs. In sample case \#3, there is one 6-stopwatch as highlighted below. - 1007 100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
