#642
Unrated
Flight Routes
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

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

A flight route from city aa to city bb (a<ba<b) is a sequence of k2k\ge 2 cities a=c1<c2<<ck=ba=c_1<c_2<\dots<c_k=b such that for each 1i<k1\le i<k, there is a direct flight from city cic_i to city ci+1c_{i+1}. For every pair of cities (i,j)(i,j) with i<ji<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 NN.

Then follow N1N-1 lines. The iith line contains NiN-i integers. The jjth integer of the iith line is equal to the parity of the number of flight routes from ii to i+ji+j.

출력

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

예제 입력 1

3
11
1

예제 출력 1

2

예제 입력 2

5
1111
101
01
1

예제 출력 2

6

점수

Inputs 3-4: N6N\le 6Inputs 5-12: N100N\le 100Inputs 13-22: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.