Logo
(追記) (追記ここまで)

27395번 - Toll Roads 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB41151546.875%

문제

Your state has a number of cities, and the cities are connected by roads. Unfortunately, all of the roads are toll roads!

You now run the local chapter of AAA (American Automobile Association), and people are constantly asking you about the tolls. In particular, they've been asking about individual tolls on any single road on a path between two cities. Odd, but that's what they've been asking!

Given a description of the cities in your state and the roads that connect them, and a series of queries consisting of two separate cities, for each query determine two things:

  • First, the smallest value such that there is a route between the two cities where no road has a toll greater than that value.
  • Second, the number of cities reachable from your starting city using no road with a toll greater than that first value.

입력

The first line of input contains three integers $n$ (2ドル \le n \le 2 \times 10^5$), $m$ (1ドル \le m \le 2 \times 10^5$) and $q$ (1ドル \le q \le 2 \times 10^5$), where $n$ is the number of cities, $m$ is the number of roads, and $q$ is the number of queries. The cities are each identified by a number 1ドル$ through $n$.

Each of the next $m$ lines contains three integers $u,ドル $v$ (1ドル \le u,v \le n, u \ne v$) and $t$ (0ドル \le t \le 2 \times 10^5$), which represents a road between cities $u$ and $v$ with toll $t$. The roads are two-way, and the toll is the same in either direction. It is guaranteed that there is a path between any two cities, and that there is at most one road between any two cities.

Each of the next $q$ lines contains two integers $a$ and $b$ ( 1ドル \le a,b \le n, a \ne b$). This represents a query about a path from $a$ to $b$.

출력

Output $q$ lines. Each line is an answer to a query, in the order that they appear. Output two space-separated integers, $w$ and $k,ドル on each line, where $w$ is the smallest amount such that there is a route from $a$ to $b$ with no toll greater that $w,ドル and $k$ is the number of cities reachable from $a$ using no road with a toll greater than $w$.

제한

예제 입력 1

4 3 6
1 2 1
2 3 3
3 4 2
1 2
1 3
1 4
2 3
2 4
3 4

예제 출력 1

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

힌트

출처

ICPC > Regionals > North America > North America Qualification Contest > ICPC North America Qualifier 2022 M번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /