QOJ.ac

QOJ

Süre Sınırı: 1.0 s Bellek Sınırı: 512 MB Toplam puan: 100 Hack'lenebilir ✓

#7321. กราฟแฮมิลโทเนียนที่มีความเชื่อมโยงจุดยอด $k$

İstatistikler

กราฟ (ที่ไม่ใช่กราฟบริบูรณ์) มีค่าความเชื่อมโยง $k$ หาก $k$ คือขนาดของสับเซตของจุดยอดที่เล็กที่สุด ซึ่งเมื่อลบจุดยอดเหล่านั้นแล้ว กราฟจะไม่เชื่อมต่อกัน

กราฟไม่มีทิศทางที่เชื่อมต่อกัน $G$ เรียกว่ากราฟแฮมิลโทเนียน หากมีวงจรแฮมิลโทเนียน ซึ่งเป็นวงจรที่ผ่านจุดยอดแต่ละจุดหนึ่งครั้งพอดี (ยกเว้นจุดยอดที่เป็นทั้งจุดเริ่มต้นและจุดสิ้นสุดซึ่งผ่านสองครั้ง)

Bobo ต้องการสร้างกราฟแฮมิลโทเนียนที่มีจุดยอด $n$ จุดและมีค่าความเชื่อมโยง $k$ นอกจากนี้ จำนวนเส้นเชื่อมในกราฟต้องน้อยที่สุดเท่าที่เป็นไปได้

ข้อมูลนำเข้า

บรรทัดแรกมีจำนวนเต็มสองจำนวน $n$ และ $k$ โดย $n$ คือจำนวนจุดยอดในกราฟ ($3 \le n \le 100$, $1 \le k \le n-2$)

ข้อมูลส่งออก

หากไม่มีกราฟดังกล่าว ให้พิมพ์ $-1$ เพียงบรรทัดเดียว มิฉะนั้น ให้พิมพ์จำนวนเต็ม $m$ แทนจำนวนเส้นเชื่อมที่น้อยที่สุด จากนั้นแต่ละบรรทัดใน $m$ บรรทัดถัดไป ให้พิมพ์จำนวนเต็มสองจำนวน $x$ และ $y$ ($1 \le x,y \le n$, $x \ne y$) แทนเส้นเชื่อมในกราฟ ในบรรทัดถัดจากนั้น ให้พิมพ์การเรียงสับเปลี่ยนของจำนวนเต็ม $1,2,\ldots,n$ ซึ่งแทนวงจรแฮมิลโทเนียนในกราฟ

ตัวอย่าง

ข้อมูลนำเข้า 1

4 2

ข้อมูลส่งออก 1

4
1 2
2 3
3 4
4 1
1 2 3 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.