CF803G.Periodic RMQ Problem

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array aa consisting of positive integers and qq queries to this array. There are two types of queries:

  • 11 ll rr xx — for each index ii such that l<=i<=rl<=i<=r set ai=xa_{i}=x .
  • 22 ll rr — find the minimum among such aia_{i} that l<=i<=rl<=i<=r .

We decided that this problem is too easy. So the array aa is given in a compressed form: there is an array bb consisting of nn elements and a number kk in the input, and before all queries aa is equal to the concatenation of kk arrays bb (so the size of aa is nkn·k ).

输入格式

The first line contains two integers nn and kk ( 1<=n<=1051<=n<=10^{5} , 1<=k<=1041<=k<=10^{4} ).

The second line contains nn integers — elements of the array bb ( 1<=bi<=1091<=b_{i}<=10^{9} ).

The third line contains one integer qq ( 1<=q<=1051<=q<=10^{5} ).

Then qq lines follow, each representing a query. Each query is given either as 11 ll rr xx — set all elements in the segment from ll till rr (including borders) to xx ( 1<=l<=r<=nk1<=l<=r<=n·k , 1<=x<=1091<=x<=10^{9} ) or as 22 ll rr — find the minimum among all elements in the segment from ll till rr ( 1<=l<=r<=nk1<=l<=r<=n·k ).

输出格式

For each query of type 22 print the answer to this query — the minimum on the corresponding segment.

输入输出样例

  • 输入#1

    3 1
    1 2 3
    3
    2 1 3
    1 1 2 4
    2 1 3
    

    输出#1

    1
    3
    
  • 输入#2

    3 2
    1 2 3
    5
    2 4 4
    1 4 4 5
    2 4 4
    1 1 6 1
    2 6 6
    

    输出#2

    1
    5
    1
    
首页