Universal Cup Judging System

Universal Cup

حد الوقت: 3.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100
الإحصائيات

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

มีคำถาม $q$ ข้อ แต่ละคำถามคือคู่อันดับ $(x, y)$ คุณต้องพิจารณาว่าระยะทางระหว่าง $x$ และ $y$ มีค่ามากกว่า $20\,000$ อย่างแท้จริงหรือไม่

ระยะทางระหว่างจุดยอดสองจุดคือจำนวนเส้นเชื่อมบนวิถีที่สั้นที่สุดระหว่างจุดยอดทั้งสอง หากไม่มีวิถีที่สั้นที่สุด ให้ถือว่าระยะทางเป็น $+\infty > 20\,000$

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

บรรทัดแรกประกอบด้วยจำนวนเต็มสามจำนวน $n$, $m$ และ $q$ ($1 \le n \le 10^5$, $0 \le m \le 3 \cdot 10^5$, $1 \le q \le 3 \cdot 10^5$)

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

หลังจากนั้นอีก $q$ บรรทัด แต่ละบรรทัดประกอบด้วยจำนวนเต็มสองจำนวน $x_i$ และ $y_i$ ($1 \le x_i, y_i \le n$ โดยที่ $x_i$ และ $y_i$ อาจเป็นจุดเดียวกันได้)

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

พิมพ์ $q$ บรรทัด แต่ละบรรทัดเป็น "YES" หรือ "NO": คำตอบของคำถามแต่ละข้อ

ตัวอย่าง

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

10 5 10
1 2
1 7
3 10
4 10
5 6
3 3
5 6
5 2
10 6
9 4
6 6
1 7
10 1
10 5
8 7

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

NO
NO
YES
YES
YES
NO
NO
YES
YES
YES

หมายเหตุ

ในตัวอย่าง มีจุดยอดเพียง $10$ จุดในกราฟ ดังนั้นเราจึงกำลังตรวจสอบว่าจุดยอดเหล่านั้นอยู่ในส่วนประกอบที่เชื่อมต่อกัน (connected components) คนละส่วนกันหรือไม่

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.