Universal Cup Judging System

Universal Cup

時間限制: 3.0 s 記憶體限制: 1024 MB 總分: 100
统计

$n$ 個の頂点と $m$ 本の辺を持つ無向グラフがあります。このグラフは自己ループや多重辺を含まず、必ずしも連結であるとは限りません。頂点には $1$ から $n$ までの番号が付けられています。

$q$ 個のクエリが与えられます。各クエリはペア $(x, y)$ です。$x$ と $y$ の間の距離が $20\,000$ より真に大きいかどうかを判定してください。

2 つの頂点間の距離とは、それらを結ぶ最短経路に含まれる辺の本数です。最短経路が存在しない場合、距離は $+\infty > 20\,000$ であるとみなします。

入力

1 行目には 3 つの整数 $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$ 行が与えられ、各行には辺を表す 2 つの整数 $u_i$ と $v_i$($1 \le u_i < v_i \le n$、どの 2 本の辺も一致しない)が含まれます。

その後、$q$ 行が続き、各行には 2 つの整数 $x_i$ と $y_i$($1 \le x_i, y_i \le n$、$x_i$ と $y_i$ は一致する場合がある)が含まれます。

出力

クエリの答えとして、「YES」または「NO」のいずれかを $q$ 行に出力してください。

入出力例

入力例 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$ 個しかないため、実際には 2 つの頂点が異なる連結成分に属しているかどうかを調べています。

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.