Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 406 Weeks Ago, 2 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 16 Sep 2017 My Price 9.00

number of test cases

Anup has N boxes. He painted them.

He wants to pick W adjacent boxes and give it to Suraj on his birthday. He wants all the W boxes he gifts to be of same colour. Anup repaints some of the boxes, and asks how many ways are there to gift W boxes to Suraj. Can you please help him out?

Input

  • 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 line of each test case contains a two integers N denoting the number of boxes and W denoting the number of adjacent boxes that he wants to gift Suraj. The second line contains N space-separated integers A1, A2, ..., AN denoting the initial colours of the boxes.
  • Third line of each test case contains a single integer Q, denoting the number of times Anup repainted a box. Q lines follow, each containing two integers Posi and Coli meaning that Posth box was repainted with colour Col.

Output

  • After each repainting query, output the number of ways Anup can gift Suraj W adjacent boxes of the same colour.

Constraints

  • 1 = T = 10
  • 1 = W, Pos = N
  • 1 = Ai, Col = 109
  • For 30 points : 1 = Q = 103, 1 = N = 104
  • For 70 points : 1 = Q = 104, 1 = N = 105

Example

Input: 1 4 2 1 1 1 1 3 1 1 1 2 2 2 Output: 3 2 2

Explanation

After the first repaint the boxes are coloured (1,1,1,1), which means 3 ways to choose 2 adjacent boxes of the same colour.
After the second repaint the boxes are coloured (2,1,1,1), which means 2 ways to select 2 adjacent boxes of the same colour.
After the third repaint thee boxes are coloured (2,2,1,1), which means 2 ways to select 2 adjacent boxes of the same colour.

Answers

(5)
Status NEW Posted 16 Sep 2017 02:09 PM My Price 9.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)