시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB58929226950.375%

문제

The Quechuas welcome you to IOI 2025 with a special gift: two arrays, $A$ and $B$, each of length $N$. The elements in both arrays are indexed from $0$ to $N − 1$.

To ensure that you are taking good care of their gift, they will ask you $Q$ questions, one at a time. Each question consists of two indices, $i$ and $j$, and asks: What is the sum of $A[i]$ and $B[j]$?

구현 상세

The first procedure you should implement is:

void initialize(std::vector<int> A, std::vector<int> B)
  • $A$, $B$: two arrays of length $N$, the gift of the Quechuas.
  • This procedure is called exactly once for each testcase, before any calls to answer_question.

The second procedure you should implement is:

int answer_question(int i, int j)
  • $i$, $j$: integers describing a question.
  • This procedure is called $Q$ times.

This procedure should return the sum of $A[i]$ and $B[j]$.

제한

  • $1 ≤ N ≤ 200\, 000$
  • $0 ≤ A[k],B[k] ≤ 10$ for each $k$ such that $0 ≤ k < N$.
  • $1 ≤ Q ≤ 200\, 000$
  • $0 ≤ i, j < N$ in each question.

서브태스크

번호배점제한
125

All elements in array $A$ are equal and all elements in array $B$ are equal.

235

$N ≤ 1000$

340

No additional constraints.

예제

Consider the following call:

initialize([2, 1, 3], [0, 7, 8])

In this case $N = 3$ and the two arrays gifted to you are $A = [2, 1, 3]$ and $B = [0, 7, 8]$.

Now consider the following call:

answer_question(0, 1)

This call should return the sum of $A[0] = 2$ and $B[1] = 7$, which is $9$.

Consider the following call:

answer_question(2, 2)

This call should return $A[2] + B[2] = 3 + 8 = 11$.

샘플 그레이더

Input format:

N
A[0] A[1] ... A[N-1]
B[0] B[1] ... B[N-1]
Q
i[0] j[0]
i[1] j[1]
...
i[Q-1] j[Q-1]

Here, $i[k]$ and $j[k]$ ($0 ≤ k < Q$) specify the parameters for each call to answer_question.

Output Format:

S[0]
S[1]
...
S[Q-1]

Here, $S[k]$ ($0 ≤ k < Q$) is the integer returned by the call answer_question(i[k], j[k]).

첨부

제출할 수 있는 언어

C++17, C++20, C++23, C++26, C++17 (Clang), C++20 (Clang)

채점 및 기타 정보

  • 예제는 채점하지 않는다.