Problem A
Neighborhood Watch
Jennifer was nominated to be neighborhood watch captain and is now in charge of managing the watch for her street.
Jennifer’s street consists of houses on only one side of the road. She has a plan of which houses will be a neighborhood watch house and wants to know how safe the plan is. A walk from one house to another house (not necessarily distinct) is considered safe if there is at least one house along the walk that is a neighborhood watch house. The safety rating of a plan is the number of walks that are safe on the street. Since a walk is either safe or not safe, when traveling in either direction, it is not counted twice in the safety rating.
![\includegraphics[width=0.7\textwidth ]{houses}](/problems/neighborhoodwatch/file/statement/en/img-0001.png)
Tell Jennifer the safety rating of her plan.
Input
The first line of input contains two integers
The next
Output
Display the safety rating of Jennifer’s plan.
Sample Input 1 | Sample Output 1 |
---|---|
5 2 1 4 |
11 |