RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00402

Torrent

Unrated 레이팅 미적용
난이도
1s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Mirko works at a data centre and today’s task is to copy a file sized 1 GiB to \(n\) computers. The computers
are denoted with integers from 1 to \(n\) and are connected so that they form a \(so-ca\)lled tree. More precisely,
\(n - 1\) pairs of computers are directly connected via network cable in a way that there is a unique path
between each pair of computers.
1
2
5
3
4
6
1
2
5
3
4
6
1
2
5
3
4
6
Figure 4: In the first sample test, it takes two minutes for the file to be copied to all computers.
Initially, Mirko manually placed the file on two different computers – computer \(a\) and computer \(b\) and is
now writing commands that will copy the file to all other computers. The file can be copied from computer
\(x\) to computer \(y\) only if the two computers are directly connected, and the copying process takes exactly
one minute. At any moment, each individual computer can take part in at most one copying process, but
it is allowed to have the file being copied between arbitrarily many different pairs of computers at the
same time. Therefore, when the copying process ends from computer \(x\) to computer \(y\), it is possible in the
next minute to copy the file from computer \(x\) to computer \(w\) and from computer \(y\) to computer \(z\).
Determine the minimal amount of time it takes for the file to be copied to all computers.

제약

Subtask
Score
Limitations
1
31
\(2 \le n \le 1\,000\)
2
69
\(1\,000 \le n \le 300\,000\)
7 od 8

입력 형식

The first line of input contains the integer \(n\) and two different integers \(a\) and \(b\) (\(1 \le a\), \(b \le n\)) – the number
of computers and the labels of the computers already containing the file. Each of the following \(n - 1\) lines
contains two different integers \(x\) and \(y\) (\(1 \le x\), \(y \le n\)) – the labels of the computers directly connected via
network cable. The computer network forms a tree, as described in the task.
Input
You must output the required minimal amount of time in minutes.
Scoring
Subtask
Score
Limitations
1
31
\(2 \le n \le 1\,000\)
2
69
\(1\,000 \le n \le 300\,000\)
7 od 8

출력 형식
예제 1
입력
6 2 1
1 2
2 3
2 4
1 5
5 6
출력
2
예제 2
입력
10 1 2
1 2
2 5
1 3
1 4
4 6
6 7
3 8
3 9
3 10
출력
4
예제 3
입력
17 1 2
1 3
1 4
4 6
6 7
3 8
3 9
3 10
1 13
13 5
13 11
13 12
13 14
14 15
15 16
15 17
14 2
출력
5
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2015/2016 Olympiad

평가 및 의견

Torrent

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Torrent

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8