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

Cijanobakterije

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

의견: 0

설명

Young microbiologist Maja is making a microscopic Christmas tree out of a species of
cyanobacteria called Stigonema arboreus. This species is known for its colonies made
from individual cells which link together, forming a tree graph. More precisely, for each
pair of cyanobacteria in the colony, there is a unique path through the colony from one
cyanobacterium to the other.
Maja wants her Christmas tree colony to contain a chain of cyanobacteria that is as
long as possible. A chain is determined by a sequence of cyanobacteria, where each
cyanobacterium appears at most once, and every pair of adjacent cyanobacteria are
directly linked together. Because none of the colonies she currently has is long enough,
Maja will have to connect some of the colonies together. She does this by repeatedly choosing two
cyanobacteria from different colonies, bringing them close to each other, and joining them with superglue.
Since the bacteria are sensitive to cycles, Maja has to be careful not to join two bacteria from the same
colony at any time. Using a series of such gluing procedures, Maja wants to obtain a colony which contains
the longest possible chain.
Maja is tired from using her microscope, and there a lot of cyanobacteria. Help Maja determine the length
of the longest chain of cyanobacteria she could obtain by connecting the colonies. The length of a chain is
determined by the number of cyanobacteria from which it is formed.

제약

Subtask 1 (15 points): \(m = n - 1\)

Subtask 2 (6 points): \(b_{i} = a_{i} + 1\) for each \(i = 1\), . . . , m

Subtask 3 (6 points): \(1 \le a\)\(i \le 2\) for each \(i = 1\), . . . , m

Subtask 4 (15 points): \(1 \le n \le 1000\)

Subtask 5 (28 points): No additional constrains.

입력 형식

The first line contains positive integers \(n\) and \(m\) (\(1 \le n \le 100\,000\), \(0 \le m < n\)), the number of
cyanobacteria and the number of direct connections between them.
The following \(m\) lines contain a pair of positive integers \(a@@RISE_MATH_BLOCK_0@@i\) (\(1 \le a@@RISE_MATH_BLOCK_1@@i\) and \(b\)\(i\) are directly linked. No bacterium is directly linked to itself, and no connection will be
listed more than once.
The connections are such that the bacteria form some colonies, each of which is a tree.

출력 형식

In the only line print the largest possible length of a chain in the final colony.

서브태스크
서브태스크점수설명

1

15점

\(m = n - 1\)

2

6점

\(b_{i} = a_{i} + 1\) for each \(i = 1\), . . . , m

3

6점

\(1 \le a\)\(i \le 2\) for each \(i = 1\), . . . , m

4

15점

\(1 \le n \le 1000\)

5

28점

No additional constrains.

예제 1
입력
100 0
출력
100
예제 2
입력
8 6
1 2
1 3
1 4
5 6
5 7
5 8
출력
6
예제 3
입력
6 5
1 2
2 3
3 4
4 6
4 5
출력
5
설명

Clarification of the second example:
In the second example there are two colonies of cyanobacteria. In the first colony, all cyanobacteria are
directly connected to cyanobacterium 1, and in the second with cyanobacterium 5. If any two cyanobacteria
except 1 and except 5 are connected, the resulting colony will contain the longest possible chain. Eg. if 2
and 6 are connected, one such chain will be 3 - 1 - 2 - 6 - 5 - 7 which has length 6.

문제 정보

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

출처 COCI 2021/2022 Contest 3

평가 및 의견

Cijanobakterije

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

Log in to rate problems.

개별 의견

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

풀이 제출

Cijanobakterije

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