Cycle Correspondence
의견: 0
Farmer John has \(N\) barns (\(3\le N\le 5\cdot 10^5\)), of which \(K\)
(\(3\le K\le N\)) distinct pairs of barns are connected.
First, Annabelle assigns each barn a distinct integer label in the range
\([1,N]\), and observes that the barns with labels \(a_1,\dots,a_K\) are connected
in a cycle, in that order. That is, barns \(a_i\) and \(a_{i+1}\) are connected for
all \(1\le i
distinct.
Next, Bessie also assigns each barn a distinct integer label in the range
\([1,N]\) and observes that the barns with labels \(b_1,\dots,b_K\) are connected in
a cycle, in that order. All \(b_i\) are distinct.
Some (possibly none or all) barns are assigned the same label by Annabelle and
Bessie. Compute the maximum possible number of barns that are assigned the same
label by Annabelle and Bessie.
Problem credits: Benjamin Qi
SCORING
- Inputs 4-5: \(N \le 8\)
- Inputs 6-8: \(N \le 5000\)
- Inputs 9-15: No additional constraints
Problem credits: Benjamin Qi
The first line contains \(N\) and \(K\).
The next line contains \(a_1,\dots, a_K\).
The next line contains \(b_1,\dots, b_K\).
The maximum number of fixed points.
6 3
1 2 3
2 3 16Annabelle and Bessie could have assigned the same label to every barn.
6 3
1 2 3
4 5 60Annabelle and Bessie could not have assigned the same label to any barn.
6 4
1 2 3 4
4 3 2 54Annabelle and Bessie could have assigned labels \(2,3,4,6\) to the same barns.
riseoj 작성
출처 올림피아드 > USACO > 2023-2024 > December > Silver
평가 및 의견
Cycle Correspondence
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Cycle Correspondence