| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 473 | 239 | 219 | 52.143% |
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)
answer_question.The second procedure you should implement is:
int answer_question(int i, int j)
This procedure should return the sum of $A[i]$ and $B[j]$.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 25 | All elements in array $A$ are equal and all elements in array $B$ are equal. |
| 2 | 35 | $N ≤ 1000$ |
| 3 | 40 | 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)