Toggle navigation
Bulletin
Problems
Submissions
Contests
Discuss
About
Rank
Sign in
Sign up
×
Close
NTUCPC Speed Run! #1
比賽已結束,感謝大家的參與!
題目連結
IOICamp 2025 PreExam 進行中!
IOICamp 官網
、
PreExam 連結
程式解題社網站
程式解題社網站
上線了!
457 . 蛋餅愛涉水
Submit
Status
Discussion / Solution
Ranklist
Back to Problems List
TopCoder
baluteshih
User's AC Ratio
75.0% (
3/4
)
Submission's AC Ratio
1.9% (
7
/
371
)
Tags
Show solution-related tags
ytp
ytp-senior
ytp-2024
Description
題目 PDF 檔在這裡
Input Format
Output Format
Sample Input 1
copy
9
1 2
1 3
3 4
3 5
4 6
4 7
7 8
7 9
Sample Output 1
copy
3
2
2
1
1
1
1
1
0
Sample Input 2
copy
5
3 1
2 3
4 5
1 5
Sample Output 2
copy
2
1
1
1
0
Sample Input 3
copy
16
5 3
16 11
10 11
14 16
13 15
9 13
9 12
6 7
4 6
1 8
8 10
15 2
4 3
1 2
5 1
Sample Output 3
copy
5
5
3
2
2
1
1
1
1
1
1
1
1
1
1
0
Hints
Problem Source
YTP 2024 高中組程式挑戰營 p16
Subtasks
No.
Testdata Range
Constraints
Score
1
0~2
範例測資
0
2
0~31
$N \leq 3000$
3
3
0~58
$N \leq 50000$
10
4
0~97
無額外限制
12
Testdata and Limits
No.
Time Limit (ms)
Memory Limit (VSS, KiB)
Output Limit (KiB)
Subtasks
0
6000
524288
65536
1
2
3
4
1
6000
524288
65536
1
2
3
4
2
6000
524288
65536
1
2
3
4
3
6000
524288
65536
2
3
4
4
6000
524288
65536
2
3
4
5
6000
524288
65536
2
3
4
6
6000
524288
65536
2
3
4
7
6000
524288
65536
2
3
4
8
6000
524288
65536
2
3
4
9
6000
524288
65536
2
3
4
10
6000
524288
65536
2
3
4
11
6000
524288
65536
2
3
4
12
6000
524288
65536
2
3
4
13
6000
524288
65536
2
3
4
14
6000
524288
65536
2
3
4
15
6000
524288
65536
2
3
4
16
6000
524288
65536
2
3
4
17
6000
524288
65536
2
3
4
18
6000
524288
65536
2
3
4
19
6000
524288
65536
2
3
4
20
6000
524288
65536
2
3
4
21
6000
524288
65536
2
3
4
22
6000
524288
65536
2
3
4
23
6000
524288
65536
2
3
4
24
6000
524288
65536
2
3
4
25
6000
524288
65536
2
3
4
26
6000
524288
65536
2
3
4
27
6000
524288
65536
2
3
4
28
6000
524288
65536
2
3
4
29
6000
524288
65536
2
3
4
30
6000
524288
65536
2
3
4
31
6000
524288
65536
2
3
4
32
6000
524288
65536
3
4
33
6000
524288
65536
3
4
34
6000
524288
65536
3
4
35
6000
524288
65536
3
4
36
6000
524288
65536
3
4
37
6000
524288
65536
3
4
38
6000
524288
65536
3
4
39
6000
524288
65536
3
4
40
6000
524288
65536
3
4
41
6000
524288
65536
3
4
42
6000
524288
65536
3
4
43
6000
524288
65536
3
4
44
6000
524288
65536
3
4
45
6000
524288
65536
3
4
46
6000
524288
65536
3
4
47
6000
524288
65536
3
4
48
6000
524288
65536
3
4
49
6000
524288
65536
3
4
50
6000
524288
65536
3
4
51
6000
524288
65536
3
4
52
6000
524288
65536
3
4
53
6000
524288
65536
3
4
54
6000
524288
65536
3
4
55
6000
524288
65536
3
4
56
6000
524288
65536
3
4
57
6000
524288
65536
3
4
58
6000
524288
65536
3
4
59
6000
524288
65536
4
60
6000
524288
65536
4
61
6000
524288
65536
4
62
6000
524288
65536
4
63
6000
524288
65536
4
64
6000
524288
65536
4
65
6000
524288
65536
4
66
6000
524288
65536
4
67
6000
524288
65536
4
68
6000
524288
65536
4
69
6000
524288
65536
4
70
6000
524288
65536
4
71
6000
524288
65536
4
72
6000
524288
65536
4
73
6000
524288
65536
4
74
6000
524288
65536
4
75
6000
524288
65536
4
76
6000
524288
65536
4
77
6000
524288
65536
4
78
6000
524288
65536
4
79
6000
524288
65536
4
80
6000
524288
65536
4
81
6000
524288
65536
4
82
6000
524288
65536
4
83
6000
524288
65536
4
84
6000
524288
65536
4
85
6000
524288
65536
4
86
6000
524288
65536
4
87
6000
524288
65536
4
88
6000
524288
65536
4
89
6000
524288
65536
4
90
6000
524288
65536
4
91
6000
524288
65536
4
92
6000
524288
65536
4
93
6000
524288
65536
4
94
6000
524288
65536
4
95
6000
524288
65536
4
96
6000
524288
65536
4
97
6000
524288
65536
4
Submit
Back to Top