Universal Cup Judging System

Universal Cup

حد الوقت: 1.5 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓
الإحصائيات

กำหนดกราฟมีทิศทางที่มี $n$ จุดยอดและ $m$ เส้นเชื่อม งานของคุณคือการหาความยาวของลำดับ $a$ ที่ยาวที่สุดซึ่งประกอบด้วยจำนวนเต็มที่แตกต่างกันตั้งแต่ $1$ ถึง $n$ โดยที่สอดคล้องกับเงื่อนไขต่อไปนี้:

  • ให้ $l$ เป็นความยาวของ $a$ แล้วสำหรับทุกจำนวนเต็ม $i \in [2, l]$ และทุกจุดยอด $v$ ที่มีเส้นเชื่อม $(v, a_i)$ จะต้องมีดัชนี $j < i$ ที่ทำให้ $a_j = v$

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

บรรทัดแรกมีจำนวนเต็ม $2$ จำนวน $n, m$ ($2 \le n \le 3 \cdot 10^5, 0 \le m \le 3 \cdot 10^5$) — จำนวนจุดยอดและเส้นเชื่อมของกราฟ

อีก $m$ บรรทัดถัดไปมีคู่ของจำนวนเต็ม $u_i, v_i$ ($1 \le u_i, v_i \le n$) — เส้นเชื่อมของกราฟ กราฟนี้อาจมีวงวนในตัวเองและเส้นเชื่อมซ้ำได้

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

ในบรรทัดแรก ให้แสดงผลความยาวมากที่สุดของลำดับที่ถูกต้อง $l$

ตัวอย่าง

ข้อมูลนำเข้าตัวอย่าง 1

5 0

ข้อมูลส่งออกตัวอย่าง 1

5

ข้อมูลนำเข้าตัวอย่าง 2

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

ข้อมูลส่งออกตัวอย่าง 2

5

ข้อมูลนำเข้าตัวอย่าง 3

3 3
1 1
2 2
3 3

ข้อมูลส่งออกตัวอย่าง 3

1

หมายเหตุ

ในกรณีตัวอย่างแรก ลำดับที่ถูกต้องลำดับหนึ่งอาจเป็น $\{1, 2, 3, 4, 5\}$

ในกรณีตัวอย่างที่สอง ลำดับที่ถูกต้องลำดับหนึ่งอาจเป็น $\{3, 5, 1, 2, 4\}$

ในกรณีตัวอย่างที่สาม ลำดับที่ถูกต้องลำดับหนึ่งอาจเป็น $\{1\}$ นอกจากนี้ลำดับ $\{2\}$ และ $\{3\}$ ก็สอดคล้องกับเงื่อนไขของโจทย์เช่นกัน

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#370EditorialOpen题解jianglyView

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.