QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#18125. 지루한 해 구성하기 문제

Statistics

문제 설명

세상에서 가장 지루한 해 구성하기 문제는 $n, m$을 입력받아 조건 1, 2, 3, 4, 5, 6, 7, 8을 만족하는 행렬을 출력하는 것입니다.

네 정수 $a, b, n, s$ ($a \neq b$)가 주어집니다. 다음 조건을 만족하는 길이 $n$의 수열 $c$를 구성해야 합니다:

  • 모든 $1 \le i \le n$에 대하여, $c_i \in \{a, b\}$입니다;
  • 합이 정확히 $s$가 되는 연속 부분 수열 $c_l, c_{l+1}, \dots, c_r$이 존재하지 않습니다.

더 엄밀하게는, $1 \le l \le r \le n$을 만족하면서 $c_l + c_{l+1} + \dots + c_r = s$인 정수 쌍 $(l, r)$이 존재하지 않아야 합니다.

각 테스트 케이스에 대해, 그러한 수열이 존재하는지 판별하세요:

  • 존재한다면 YES를 출력하고, 올바른 수열 중 아무것이나 하나 출력합니다;
  • 그렇지 않다면 NO를 출력합니다.

입력

첫째 줄에 테스트 케이스의 개수를 나타내는 정수 $T$ ($1 \le T \le 10^5$)가 주어집니다.

다음 $T$개의 줄에는 각각 네 정수 $a, b, n, s$ ($1 \le a, b, s \le 10^9$, $1 \le n \le 5 \cdot 10^5$, $a \neq b$)가 주어집니다.

모든 $n$의 합은 $5 \cdot 10^5$을 넘지 않음이 보장됩니다.

출력

각 테스트 케이스에 대하여:

  • 해가 없다면 NO를 한 줄에 출력합니다;
  • 해가 있다면 먼저 첫째 줄에 YES를 출력한 뒤, 다음 줄에 당신이 구성한 수열을 나타내는 $n$개의 정수를 출력합니다.

올바른 답이 여러 개라면 그중 아무것이나 출력해도 됩니다.

예제

예제 입력 1

3
2 4 6 8
2 5 5 9
3 4 3 7

예제 출력 1

NO
YES
2 5 5 5 2
YES
4 4 4

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.