Codeforces Round 202 (Div. 1)
C
Subset Sums
Codeforces
2500
原题
← BD →
翻译中…

You are given an array $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ and $*m*$ sets $*S*_{1}, *S*_{2}, ..., *S*_{*m*}$ of indices of elements of this array. Let's denote $*S*_{*k*} = {*S*_{*k*, *i*}} (1 ≤ *i* ≤ |*S*_{*k*}|)$. In other words, $*S*_{*k*, *i*}$ is some element from set $*S*_{*k*}$.

翻译中…

In this problem you have to answer $*q*$ queries of the two types:

翻译中…
  1. Find the sum of elements with indices from set $*S*_{*k*}$: image. The query format is "? k".
  2. Add number $*x*$ to all elements at indices from set $*S*_{*k*}$: $*a*_{*S*_{*k*, *i*}}$ is replaced by $*a*_{*S*_{*k*, *i*}} + *x*$ for all $*i*$ $(1 ≤ *i* ≤ |*S*_{*k*}|)$. The query format is "+ k x".
翻译中…

After each first type query print the required sum.

翻译中…

Input

翻译中…

The first line contains integers $*n*, *m*, *q*$ $(1 ≤ *n*, *m*, *q* ≤ 10^{5})$. The second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ $(|*a*_{*i*}| ≤ 10^{8})$ — elements of array $*a*$.

翻译中…

Each of the following $*m*$ lines describes one set of indices. The $*k*$-th line first contains a positive integer, representing the number of elements in set ($|*S*_{*k*}|$), then follow $|*S*_{*k*}|$ distinct integers $*S*_{*k*, 1}, *S*_{*k*, 2}, ..., *S*_{*k*, |*S*_{*k*}|}$ $(1 ≤ *S*_{*k*, *i*} ≤ *n*)$ — elements of set $*S*_{*k*}$.

翻译中…

The next $*q*$ lines contain queries. Each query looks like either "? k" or "+ k x" and sits on a single line. For all queries the following limits are held: $1 ≤ *k* ≤ *m*$, $|*x*| ≤ 10^{8}$. The queries are given in order they need to be answered.

翻译中…

It is guaranteed that the sum of sizes of all sets $*S*_{*k*}$ doesn't exceed $10^{5}$.

翻译中…

Output

翻译中…

After each first type query print the required sum on a single line.

翻译中…

Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

翻译中…

样例

Input #1
5 3 5
5 -5 5 1 -4
2 1 2
4 2 1 4 5
2 2 5
? 2
+ 3 4
? 1
+ 2 1
? 2
Output #1
-3
4
9
InputCopy OutputCopy
题目信息
题号
348C
时间限制
3 s
内存限制
256 MB
标签
暴力
数据结构

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。