CF1218E.Product Tuples

省选/NOI-

通过率:0%

时间限制:8.00s

内存限制:128MB

AC君温馨提醒

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

题目描述

While roaming the mystic areas of Stonefalls, in order to drop legendary loot, an adventurer was given a quest as follows. He was given an array A=a1,a2,...,aNA = {a_1,a_2,...,a_N } of length NN, and a number KK.

Define array BB as $B(q, A) = $ { q−a1,q−a2,...,q−aNq-a_1, q-a_2, ..., q-a_N }. Define function FF as F(B,K)F(B,K) being sum of products of all KK-tuples of elements in array BB. For example, if the array BB is [2,3,4,5][2,3,4,5], and with K=3K=3, sum of products of all 3-tuples is $$F(B, 3) = 2*3*4+2*3*5+3*4*5+2*4*5$$

He was then given a number Q, number of queries of two types:

  • Type 1: Given qq, ii, and dd calculate F(B(q,A),K)F(B(q, A), K) where we make change to initial array as A[i]=dA[i] = d.
  • Type 2: Given qq, LL, RR, and dd calculate F(B(q,A),K)F(B(q, A), K) where we make change to initial array as A[i]=A[i]+dA[i] = A[i] + d for all ii in range [L,R][L, R] inclusive.

All changes are temporarily made to initial array, and don't propagate to following queries. Help the adventurer calculate the answer to a quest, and finally get that loot!

在石落之地(Stonefalls)的神秘区域游历时,为了获取传奇战利品,一名冒险者接到如下任务:他获得了一个长度为 NN 的数组 A={a1,a2,...,aN}A = \{a_1,a_2,...,a_N\} 和一个整数 KK。

定义数组 BB 为 B(q,A)={q−a1,q−a2,...,q−aN}B(q, A) = \{q-a_1, q-a_2, ..., q-a_N\}。定义函数 FF 为:F(B,K)F(B,K) 表示数组 BB 中所有 KK 元组元素乘积之和。例如,若数组 B=[2,3,4,5]B = [2,3,4,5],且 K=3K=3,则所有三元组乘积之和为

F(B, 3) = 2\*3\*4+2\*3\*5+3\*4\*5+2\*4\*5

随后,他获得一个整数 QQ,表示有 QQ 个查询,查询分为两类:

  • 类型 1:给定 qq、ii 和 dd,计算 F(B(q,A),K)F(B(q, A), K),其中对初始数组进行临时修改:令 A[i]=dA[i] = d。
  • 类型 2:给定 qq、LL、RR 和 dd,计算 F(B(q,A),K)F(B(q, A), K),其中对初始数组进行临时修改:对所有下标 i∈[L,R]i \in [L, R](含端点),令 A[i]=A[i]+dA[i] = A[i] + d。

所有修改均为对初始数组的临时修改,不会影响后续查询。请帮助这位冒险者完成任务,最终赢得那份传奇战利品!

输入格式

In the first two lines, numbers NN (1≤N≤2∗1041 \leq N \leq 2*10^4) and KK (1≤K≤N1 \leq K \leq N), the length of initial array AA, and tuple size, followed by a1,a2,a3,…,aNa_1,a_2,a_3,…,a_N (0≤ai≤1090 \leq a_i \leq 10^9) , elements of array AA, in the next line. Then follows number QQ (Q≤10Q \leq 10), number of queries. In the next QQ lines come queries of the form:

  • 1 q i d, for type 1,
  • 2 q L R d, for type 2,

as explained above (0≤q,d≤109,1≤i,L,R≤N0 \leq q, d \leq 10^9, 1 \leq i,L,R \leq N)

前两行分别输入整数 NN(1≤N≤2×1041 \leq N \leq 2 \times 10^4)和 KK(1≤K≤N1 \leq K \leq N),表示初始数组 AA 的长度以及元组大小;接下来一行输入 a1,a2,a3,…,aNa_1, a_2, a_3, \dots, a_N(0≤ai≤1090 \leq a_i \leq 10^9),即数组 AA 的各元素。随后输入整数 QQ(Q≤10Q \leq 10),表示查询次数。接下来 QQ 行每行给出一个查询,格式为:

  • 1 q i d,表示类型 1 查询;
  • 2 q L R d,表示类型 2 查询,

如上所述(其中 0≤q,d≤1090 \leq q, d \leq 10^9,1≤i,L,R≤N1 \leq i, L, R \leq N)。

输出格式

Print QQ lines, the answers to queries, modulo 998244353998244353.

输出 QQ 行,即各查询的答案,对 998244353998244353 取模。

输入输出样例

  • 输入#1

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

    输出#1

    85
    127
    63

说明/提示

In the first query array A = [1, 2, 3, 4, 5], B = [5, 4, 3, 2, 1], sum of products of 2-tuples = 85.

In second query array A = [1, 2, 3, 4, 2], B = [5, 4, 3, 2, 4], sum of products of 2-tuples = 127

In third query array A = [1, 3, 4, 4, 5], B = [5, 3, 2, 2, 1], sum of products of 2-tuples = 63

第一次查询:数组 A = [1, 2, 3, 4, 5],B = [5, 4, 3, 2, 1],所有二元组乘积之和 = 85。

第二次查询:数组 A = [1, 2, 3, 4, 2],B = [5, 4, 3, 2, 4],所有二元组乘积之和 = 127。

第三次查询:数组 A = [1, 3, 4, 4, 5],B = [5, 3, 2, 2, 1],所有二元组乘积之和 = 63

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

首页