2011: [USACO 2023 December Contest Gold] Problem 1. Flight Routes
题目描述
Bessie recently discovered that her favorite pop artist, Elsie Swift, is performing in her new Eras Tour! Unfortunately, tickets are selling out fast, so Bessie is thinking of flying to another city to attend the concert. The Eras tour is happening in () cities labeled , and for each pair of cities with there either exists a single direct flight from to or not.
A flight route from city to city () is a sequence of cities such that for each , there is a direct flight from city to city . For every pair of cities with , you are given the parity of the number of flight routes between them (0 for even, 1 for odd).
While planning her travel itinerary, Bessie got distracted and now wants to know how many pairs of cities have direct flights between them. It can be shown that the answer is uniquely determined.
输入
Then follow lines. The integers. The th integer of the th line is equal to the parity of the number of flight routes from to .
th line contains输出
样例输入
3
11
1
样例输出
2
提示
There are two direct flights: and . There is one flight route from to and to , each consisting of a single direct flight. There is one flight route from to ().
SAMPLE INPUT:
5
1111
101
01
1
SAMPLE OUTPUT:
6
There are six direct flights . These result in the following numbers of flight routes: [expand to see graph]
Flight Route Counts: dest 1 2 3 4 5 1 0 1 1 1 3 2 0 0 1 0 1 source 3 0 0 0 0 1 4 0 0 0 0 1 5 0 0 0 0 0
which is equivalent to the sample input after taking all the numbers .
SCORING:
- Inputs 3-4:
- Inputs 5-12:
- Inputs 13-22: No additional constraints.