CF803G.Periodic RMQ Problem

提高+/省选-

通过率:0%

时间限制:4.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

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

  • 1 l r x — for each index i such that l ≤ i ≤ r set a__i = x.
  • 2 l r — find the minimum among such a__i that l ≤ i ≤ r.

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

给你一个由正整数组成的数组 aa,以及对该数组的 qq 个查询。查询分为两种类型:

  • 1 l r x — 对每个满足 l≤i≤rl \le i \le r 的下标 ii,令 ai=xa_i = x。
  • 2 l r — 在所有满足 l≤i≤rl \le i \le r 的 aia_i 中,求最小值。

我们认为该问题过于简单,因此数组 aa 以压缩形式给出:输入中包含一个长度为 nn 的数组 bb 和一个整数 kk;在执行所有查询之前,aa 等于 kk 个 bb 数组的拼接(即 aa 的长度为 n⋅kn \cdot k)。

输入格式

The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 104).

The second line contains n integers — elements of the array b (1 ≤ b__i ≤ 109).

The third line contains one integer q (1 ≤ q ≤ 105).

Then q lines follow, each representing a query. Each query is given either as 1 l r x — set all elements in the segment from l till r (including borders) to x (1 ≤ l ≤ r ≤ n·k, 1 ≤ x ≤ 109) or as 2 l r — find the minimum among all elements in the segment from l till r (1 ≤ l ≤ r ≤ n·k).

第一行包含两个整数 nn 和 kk(1≤n≤1051 \leq n \leq 10^5,1≤k≤1041 \leq k \leq 10^4)。

第二行包含 nn 个整数——数组 bb 的元素(1≤bi≤1091 \leq b_i \leq 10^9)。

第三行包含一个整数 qq(1≤q≤1051 \leq q \leq 10^5)。

接下来是 qq 行,每行表示一个查询。每个查询的形式为以下两种之一:

  • 1 l r x:将区间 [l,r][l, r](含端点)内的所有元素赋值为 xx(1≤l≤r≤n⋅k1 \leq l \leq r \leq n \cdot k,1≤x≤1091 \leq x \leq 10^9);
  • 2 l r:求区间 [l,r][l, r](含端点)内所有元素的最小值(1≤l≤r≤n⋅k1 \leq l \leq r \leq n \cdot k)。

输出格式

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

对于每个类型为 2 的查询,请输出该查询的答案——即对应区间上的最小值。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页