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).
给你一个由正整数组成的数组 a,以及对该数组的 q 个查询。查询分为两种类型:
1 l r x— 对每个满足 l≤i≤r 的下标 i,令 ai=x。2 l r— 在所有满足 l≤i≤r 的 ai 中,求最小值。
我们认为该问题过于简单,因此数组 a 以压缩形式给出:输入中包含一个长度为 n 的数组 b 和一个整数 k;在执行所有查询之前,a 等于 k 个 b 数组的拼接(即 a 的长度为 n⋅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).
第一行包含两个整数 n 和 k(1≤n≤105,1≤k≤104)。
第二行包含 n 个整数——数组 b 的元素(1≤bi≤109)。
第三行包含一个整数 q(1≤q≤105)。
接下来是 q 行,每行表示一个查询。每个查询的形式为以下两种之一:
1 l r x:将区间 [l,r](含端点)内的所有元素赋值为 x(1≤l≤r≤n⋅k,1≤x≤109);2 l r:求区间 [l,r](含端点)内所有元素的最小值(1≤l≤r≤n⋅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测评打分。不知道怎么写?