Logo
(追記) (追記ここまで)

34210번 - A + B Queries 서브태스크다국어언어 제한함수 구현

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB47323921952.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)
  • $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]).

첨부

출처

Olympiad > International Olympiad in Informatics > IOI 2025 > Practice 1번

제출할 수 있는 언어

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

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /