QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22304. תחרות הפרות

Statistics

$N$ פרות ($1 \le N \le 100$), הממוספרות $1..N$, משתתפות בתחרות תכנות. כידוע, חלקן מתכנתות טוב יותר מאחרות. לכל פרה רמת מיומנות קבועה השונה מזו של כל משתתפת אחרת.

התחרות מורכבת מכמה סבבי עימות ישיר, כל אחד בין שתי פרות. אם מיומנות $A$ גדולה משל $B$ ($1 \le A \le N;1 \le B \le N;A \ne B$), $A$ תמיד מנצחת את $B$.

Farmer John רוצה לדרג את הפרות לפי מיומנות. בהינתן תוצאות $M$ סבבים ($1 \le M \le 4{,}500$), מצאו כמה פרות אפשר לקבוע את מקומן בדירוג בדיוק. מובטח שאין סתירות בתוצאות.

קלט

קראו את הנתונים מהקלט הסטנדרטי.

  • שורה 1: שני שלמים $N$ ו-$M$ מופרדים ברווח.
  • שורות $2..M+1$: כל שורה מכילה שני שלמים $A$ ו-$B$ מופרדים ברווח, המתארים את המשתתפות ותוצאת סבב אחד (השלם הראשון $A$ הוא המנצחת).

פלט

כתבו את התוצאה לפלט הסטנדרטי.

  • שורה 1: שלם שמייצג את מספר הפרות שמקומן ניתן לקביעה.

דוגמאות

קלט 1

5 5
4 3
4 2
3 2
1 2
2 5

פלט 1

2

הסבר

פרה $2$ מפסידה לפרות $1$, $3$ ו-$4$, ולכן אינה טובה מאף אחת מהן. פרה $5$ מפסידה ל-$2$, ולכן $2$ טובה מ-$5$. לפיכך $2$ חייבת להיות רביעית ו-$5$ חמישית. אי אפשר לקבוע את מקומן של הפרות האחרות.

מחבר הבעיה: Neal Wu, 2007

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.