Stella and colourful tree Problem Statement:
While returning from Byteland, Stella got one tree with N nodes from her friend over there.
All nodes in this tree are colourless and Stella decided to fill colours to make it colourful.
Stella wants it to look beautiful and decided to color it in such a way that any 2 nodes u and v with shortest distance between u and v <= 2 can not be of same colour. She is wondering how many different colors she needs if she fills it optimally.
Input Format: The first line contains single integer n (3 ≤ n ≤ 100) — the number of nodes in the tree.
Each of the next (n - 1) lines contains two integers x and y (1 ≤ x, y ≤ n) — the indices of two nodes directly connected by an edge.
It is guaranteed that any node is reachable from any other using the edges.
Output Format: In the first line print single integer k — the minimum number of colors Stella has to use. Sample Input 1:
3
2 3
1 3
Sample Output 1: 3
Explanation Output 1: Tree is like : 1->3->2
We can colour as follows:
1: Colour a 3: colour b 2: Colour c Total 3 colours
Sample Input 2
: 5
2 1
3 2
4 3
5 4
Sample Output 2: 3
Explanation Output 2: Tree is like : 1->2->3->4->5
We can colour as follows:
1: Colour a
2: colour b
3: Colour c
4: Colour a
5: Colour b
Total 3 colours
Q2.
The Girls in Tech Hackathon is a code-a-thon where developers, designers, scientists, students, entrepreneurs and educators gather to collaborate on projects including applications, software, hardware, data visualization and platform solutions.
The Participants are sitting around a round table, and they are numbered from team 1 to team n in the clockwise direction.This means that the Participant are numbered 1,2...,n-1,n and participants 1 and n are sitting next to each other. After the Hackathon duration, judges started reviewing the performance of each participant. However, some of participants haven't finished the project. Each participant i needs ti extra minutes to complete their Project.
Judges started reviewing the projects sequentially in the clockwise direction, starting with team x, and it takes them exactly 1 minute to review each project. This means the team x gets no extra time to work, whereas team x+1 gets 1 min more to work and so on. Even if the project is not completed by participant, but still the judges spend 1 min to understand the idea and rank the participant.
Input Format:
The first line contains a single positive integer, n, denoting the number of participants in the hackathon.
given the values of t1, t2, t3.. tn extra time requires by each participant to complete the project.You have to guide judges in selecting the best team x to start reviewing the project so that number of participants able to complete their projects are maximal.
Output Format:
Print x on a new line. If there are multiple such teams, select the smallest one.
Constraints:
1<=n<=9*10^5
0<=ti<=n
Sample Input:
3
1 0 0
Sample Output:
2
Description:
Entire hackathon has 3 teams
if x =1 then only 2 teams will finish. The first team needs 1 extra minute to complete their project. If judges starts reviewing here, this team will never finish their project. teams 2 and 3's project are already finished, so their projects are ready when judges review them in the second and third minutes.
if x=2 and x=3 then all 3 teams can complete their project as x=2 is smallest then return x=2.