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.