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$) คุณต้องสร้างลำดับ $c$ ที่มีความยาว $n$ โดยที่:

  • สำหรับทุกๆ $1 \le i \le n$, $c_i \in \{a, b\}$;
  • ไม่มีอาร์เรย์ย่อยติดกัน $c_l, c_{l+1}, \dots, c_r$ ใดที่มีผลรวมเท่ากับ $s$ พอดี

กล่าวอย่างเป็นทางการคือ ไม่มีคู่จำนวนเต็ม $(l, r)$ ที่สอดคล้องกับ $1 \le l \le r \le n$ ที่ทำให้ $c_l + c_{l+1} + \dots + c_r = s$

สำหรับแต่ละกรณีทดสอบ จงตรวจสอบว่ามีลำดับดังกล่าวหรือไม่:

  • หากมี ให้พิมพ์ 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.