QOJ.ac

QOJ

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

#18125. Boring Constructive Problem

Statistics

Description

The most boring constructive problem in the world is to read $n, m$ and output a matrix satisfying conditions 1, 2, 3, 4, 5, 6, 7, 8.

Given four integers $a, b, n, s$ ($a \neq b$). You need to construct a sequence $c$ of length $n$ such that:

  • For every $1 \le i \le n$, $c_i \in \{a, b\}$;
  • There does not exist a contiguous subarray $c_l, c_{l+1}, \dots, c_r$ whose sum is exactly $s$.

More formally, there do not exist integers $(l, r)$ satisfying $1 \le l \le r \le n$ such that $c_l + c_{l+1} + \dots + c_r = s$.

For each test case, determine whether such a sequence exists:

  • If it exists, output YES, and output any valid sequence;
  • Otherwise, output NO.

Input

The first line contains an integer $T$ ($1 \le T \le 10^5$), denoting the number of test cases.

Each of the next $T$ lines contains four integers $a, b, n, s$ ($1 \le a, b, s \le 10^9$, $1 \le n \le 5 \cdot 10^5$, $a \neq b$).

It is guaranteed that the sum of all $n$ does not exceed $5 \cdot 10^5$.

Output

For each test case:

  • If there is no solution, output a line containing NO;
  • If there is a solution, first output a line containing YES, then output a line containing $n$ integers representing the sequence you constructed.

If there are multiple valid answers, output any of them.

Examples

input1

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

output1

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.