Toggle navigation
Bulletin
Problems
Submissions
Contests
Discuss
About
Rank
Sign in
Sign up
×
Close
NTUCPC Speed Run! #1
比賽已結束,感謝大家的參與!
題目連結
IOICamp 2025 PreExam 進行中!
IOICamp 官網
、
PreExam 連結
程式解題社網站
程式解題社網站
上線了!
439 . 植樹問題
Submit
Status
Discussion / Solution
Ranklist
Back to Problems List
TopCoder
Caido
主唱太拼命了
User's AC Ratio
77.8% (
7/9
)
Submission's AC Ratio
52.0% (
13
/
25
)
Tags
Show solution-related tags
ytp
ytp-senior
ytp-2024
Description
題目 PDF 檔在這裡
Input Format
Output Format
Sample Input 1
copy
5 10
1 1 1 1 1
1 2
2 3
3 4
4 5
Sample Output 1
copy
3
Sample Input 2
copy
7 20
8 2 1 7 1 10 2
3 7
7 6
6 1
3 5
1 2
1 4
Sample Output 2
copy
21
Sample Input 3
copy
2 100
1 1
1 2
Sample Output 3
copy
-1
Hints
Problem Source
YTP 2024 高中組初賽 p6
Subtasks
No.
Testdata Range
Constraints
Score
1
0~2
範例測資
0
2
0~12
$1 \leq N, K \leq 200$
4
3
13~18
給定的樹是一條鍊
4
4
0~27
無額外限制
12
Testdata and Limits
No.
Time Limit (ms)
Memory Limit (VSS, KiB)
Output Limit (KiB)
Subtasks
0
6000
1048576
65536
1
2
4
1
6000
1048576
65536
1
2
4
2
6000
1048576
65536
1
2
4
3
6000
1048576
65536
2
4
4
6000
1048576
65536
2
4
5
6000
1048576
65536
2
4
6
6000
1048576
65536
2
4
7
6000
1048576
65536
2
4
8
6000
1048576
65536
2
4
9
6000
1048576
65536
2
4
10
6000
1048576
65536
2
4
11
6000
1048576
65536
2
4
12
6000
1048576
65536
2
4
13
6000
1048576
65536
3
4
14
6000
1048576
65536
3
4
15
6000
1048576
65536
3
4
16
6000
1048576
65536
3
4
17
6000
1048576
65536
3
4
18
6000
1048576
65536
3
4
19
6000
1048576
65536
4
20
6000
1048576
65536
4
21
6000
1048576
65536
4
22
6000
1048576
65536
4
23
6000
1048576
65536
4
24
6000
1048576
65536
4
25
6000
1048576
65536
4
26
6000
1048576
65536
4
27
6000
1048576
65536
4
Submit
Back to Top