Logo
(追記) (追記ここまで)

31057번 - Flight Routes 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB1791229664.865%

문제

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 $N$ (2ドル\le N\le 750$) cities labeled 1ドル\dots N,ドル and for each pair of cities $(i,j)$ with $i<j$ there either exists a single direct flight from $i$ to $j$ or not.

A flight route from city $a$ to city $b$ ($a<b$) is a sequence of $k\ge 2$ cities $a=c_1<c_2<\dots<c_k=b$ such that for each 1ドル\le i<k,ドル there is a direct flight from city $c_i$ to city $c_{i+1}$. For every pair of cities $(i,j)$ with $i<j,ドル 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.

입력

The first line contains $N$.

Then follow $N-1$ lines. The $i$th line contains $N-i$ integers. The $j$th integer of the $i$th line is equal to the parity of the number of flight routes from $i$ to $i+j$.

출력

Output the number of pairs of cities with direct flights between them.

제한

예제 입력 1

3
11
1

예제 출력 1

2

There are two direct flights: 1ドル\to 2$ and 2ドル\to 3$. There is one flight route from 1ドル$ to 2ドル$ and 2ドル$ to 3ドル,ドル each consisting of a single direct flight. There is one flight route from 1ドル$ to 3ドル$ (1ドル\to 2\to 3$).

예제 입력 2

5
1111
101
01
1

예제 출력 2

6

There are six direct flights 1ドル\to 2, 1\to 4, 1\to 5, 2\to 3, 3\to 5, 4\to 5$. These result in the following numbers of flight routes:

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 $\pmod{2}$.

힌트

출처

Olympiad > USA Computing Olympiad > 2023-2024 Season > USACO 2023 December Contest > Gold 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /