Easy Array Counting II#12269

Easy Array Counting II (Editoryal)

Problem Author:

Hasan Saleh (MathModel)

Prepared by:

Hasan Saleh (MathModel)

Edited by:

Hasan Saleh (MathModel)

Solution

Claim. doesn't matter.

Observation : If any a_i \neq a_{i+1} then there exists at least one subarray such that it's not a palindrome.

Thus from that we've a sufficient condition that a_1=a_2=a_3=...=a_n to hold , thus we've r-l+1 choices which are [l,l,..,l] ,... , [l+1,l+1,l+1,...,l+1] , and so on upto .. [r,r,...,r].

Solution is r-l+1 , Complexity .

Complexity .

for _ in range(int(input())):
   n,l,r=map(int,input().split())
   print(r-l+1)