QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 512 MB Puntuación total: 100 Hackeable ✓

#7321. גרף המילטוני בעל קשירות קודקודים $k$

Estadísticas

לגרף (שאינו גרף מלא) יש קשירות $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.