← 返回 capitalone 的题目列表Count Pair Sums with Point Updates
类型:online_judge
Given two integer arrays a and b, and a list of queries, process the queries in order.
There are two types of queries:
[0, x]: Count the number of index pairs (i, j) such that:
a[i] + b[j] == x
Append this count to the answer array.
[1, z, y]: Update a[z] to y:
a[z] = y
Return the answers for all type-0 queries.
Input Format
n m
a, length n
b, length m
q
then q query lines:
0 x
or
1 z y
Output Format
Print all answers for [0, x] queries, separated by spaces.
Constraints
1 <= n, m <= 10^5
1 <= q <= 10^5
-10^9 <= a[i], b[j], x, y <= 10^9
0 <= z < n
Example
Input
2 3
1 2
2 3 4
3
0 4
1 0 3
0 4
Output
2 1