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

25094번 - Equal Sum 서브태스크다국어인터랙티브채점 준비 중

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 1024 MB0000.000%

문제

You are given a set of distinct integers. You need to separate them into two non-empty subsets such that each element belongs to exactly one of them and the sum of all elements of each subset is the same.

An anonymous tip told us that the problem above was unlikely to be solved in polynomial time (or something like that), so we decided to change it. Now you get to decide what half of the integers are!

This is an interactive problem with three phases. In phase 1, you choose $\mathbf{N}$ distinct integers. In phase 2, you are given another $\mathbf{N}$ integers that are distinct from each other and from the ones you chose in phase 1. In phase 3, you have to partition those 2ドル\mathbf{N}$ integers into two subsets, both of which sum to the same amount. All 2ドル\mathbf{N}$ integers are to be between 1ドル$ and 10ドル^9,ドル inclusive, and it is guaranteed that they sum up to an even number.

입력과 출력

This is an interactive problem.

Initially, your program should read a single line containing an integer, $\mathbf{T},ドル the number of test cases. Then, $\mathbf{T}$ test cases must be processed.

For each test case, your program must first read a line containing a single integer $\mathbf{N}$. Then, it must output a line containing $\mathbf{N}$ distinct integers $A_1, A_2, \dots, A_\mathbf{N}$. Each of these integers must be between 1ドル$ and 10ドル^9,ドル inclusive. After that, your program must read a line containing $\mathbf{N}$ additional integers $\mathbf{B_1}, \mathbf{B_2}, \dots, \mathbf{B_N}$. Finally, your program must output a line containing between 1ドル$ and 2ドル\mathbf{N}-1$ integers from among $A_1, A_2, \dots, A_\mathbf{N}, \mathbf{B_1}, \mathbf{B_2}, \dots, \mathbf{B_N}$: the ones chosen to be part of the first subset. The integers from $A$ and $\mathbf{B}$ that you do not output are considered to be part of the other subset.

The next test case starts immediately if there is one. If this was the last test case, the judge will expect no more output and will send no further input to your program. In addition, all $\mathbf{T}$ test cases are always processed, regardless of whether the final output from your program is correct or not.

Note: It can be shown that given the limits for this problem, there exists a sequence $A_1, A_2, \dots, A_\mathbf{N}$ such that any sequence $\mathbf{B_1}, \mathbf{B_2}, \dots, \mathbf{B_N}$ results in a set of 2ドル\mathbf{N}$ integers that can be separated into two subsets with equal sums.

If the judge receives an invalidly formatted or invalid line (like outputting an unexpected number of integers, or integers out of range, or repeated integers in a line) from your program at any moment, the judge will print a single number $-1$ and will not print any further output. If your program continues to wait for the judge after receiving a $-1,ドル your program will time out, resulting in a Time Limit Exceeded error. Notice that it is your responsibility to have your program exit in time to receive a Wrong Answer judgment instead of a Time Limit Exceeded error. As usual, if the memory limit is exceeded, or your program gets a runtime error, you will receive the appropriate judgment.

입력

출력

제한

Test Set 1 (31점)

  • 1ドル \le \mathbf{T} \le 100$.
  • $\mathbf{N} = 100$.
  • 1ドル \le \mathbf{B_i} \le 10^9,ドル for all $i$.
  • $\mathbf{B_i} \neq A_j,ドル for all $i, j$.
  • $\mathbf{B_i} \neq \mathbf{B_j},ドル for all $i \neq j$.
  • For each test case, the judge will choose the $\mathbf{B_i}$s such that the sum of all 2ドル\mathbf{N}$ integers is even.

예제 입력 1

2
3
10 4 9
3
10 8 12

예제 출력 1

5 1 3
1 10 5
5 2 3
12 8

힌트

In the sample interaction above, the solution gets all cases right and would receive a correct verdict. Notice that the value for $\mathbf{N}$ does not conform to the limits for the Test Set and is used to simplify the example only. Notice that the judge could have given the solution the integers $\{2, 7, 100\}$ for the first case, making it impossible for the solution to find a valid partition into subsets of equal sum.

테스팅 툴

출처

Contest > Google > Code Jam > Google Code Jam 2022 > Round 1A B번

채점 및 기타 정보

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

출처

대학교 대회

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

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