CF2184E.Exquisite Array
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
We call an array of numbers k-exquisite if it has at least two elements and any two adjacent numbers differ by at least k.
You are given a permutation∗ p of length n. For each k from 1 to n−1, find the number of k-exquisite subarrays†.
∗A permutation of length n is an array that contains each integer from 1 to n exactly once, in any order.
†A subarray of an array is a sequence of one or more consecutive elements of the array.
我们称一个数字数组为 k-精致的,如果它至少包含两个元素,且任意两个相邻数字之差的绝对值至少为 k。
给定一个长度为 n 的排列∗ p。对每个从 1 到 n−1 的 k,求出 p 中 k-精致子数组† 的个数。
∗ 长度为 n 的排列是指由 1 到 n 中每个整数恰好出现一次(顺序任意)所构成的数组。
† 数组的一个子数组是指该数组中一个或多个连续元素所组成的序列。
输入格式
Each test consists of several test cases. The first line contains a single integer t (1≤t≤25000) — the number of test cases. The descriptions of the test cases follow.
In the first line of each test case, an integer n is given — the length of the permutation (2≤n≤105).
In the second line of each test case, n integers pi are given — the elements of the permutation (1≤pi≤n). It is guaranteed that pi are distinct.
It is guaranteed that the sum of n across all test cases does not exceed 2⋅105.
每个测试包含若干测试用例。第一行包含一个整数 t(1≤t≤25000),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例的第一行给出一个整数 n,表示排列的长度(2≤n≤105)。
每个测试用例的第二行给出 n 个整数 pi,表示该排列的元素(1≤pi≤n)。保证所有 pi 互不相同。
保证所有测试用例的 n 之和不超过 2⋅105。
输出格式
For each test case, output the number of k-exquisite subarrays for all k from 1 to n−1.
对于每个测试用例,输出所有 k(从 1 到 n−1)对应的 k-精致子数组的个数。
输入输出样例
输入#1
3 5 5 1 4 2 3 3 3 2 1 4 3 1 2 4
输出#1
10 6 3 1 3 0 6 2 0
输入解题思路,AI测评打分。不知道怎么写?