You are a teacher at the brand new Little Coders kindergarten. You have
Your lesson plan for tomorrow includes an activity in which the participants must sit in a circle. You want to make the activity as successful as possible by building the largest possible circle of kids such that each kid in the circle is sitting directly next to their BFF, either to the left or to the right. Any kids not in the circle will watch the activity without participating.
What is the greatest number of kids that can be in the circle?
Input Specification
The first line of the input gives the number of test cases,
Output Specification
For each test case, output one line containing Case #x: y
, where
Limits
Time limit: 20 seconds per test set.
Memory limit: 1 GB.
Small Dataset
Large Dataset
Sample Input
4
4
2 3 4 1
4
3 3 4 1
4
3 3 4 3
10
7 8 10 10 9 2 9 6 3 3
Sample Output
Case #1: 4
Case #2: 3
Case #3: 3
Case #4: 6
In sample case #4, the largest possible circle seats the following kids in the
following order: 7 9 3 10 4 1
. (Any reflection or rotation of this
circle would also work.) Note that the kid with student ID
Comments