Universal Cup Judging System

Universal Cup

Limite de temps : 2.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓
Statistiques

問題文

世界で最も退屈な構築問題は、$n, m$ を読み込んで条件 1, 2, 3, 4, 5, 6, 7, 8 を満たす行列を出力することです。

4 つの整数 $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$ を満たす整数の組 $(l, r)$ であって、$c_l + c_{l+1} + \dots + c_r = s$ となるものが存在しないということです。

各テストケースについて、このような数列が存在するかどうかを判定してください:

  • 存在する場合は YES を出力し、条件を満たす数列を 1 つ出力する;
  • 存在しない場合は NO を出力する。

入力

1 行目には、テストケースの個数を表す整数 $T$ ($1 \le T \le 10^5$) が与えられます。

続く $T$ 行のそれぞれには、4 つの整数 $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.