RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0585

Flight Routes

Gold I 골드 I
난이도
2s
시간 제한
256MB
메모리 제한
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 \(N\) (\(2\le N\le 750\)) cities labeled \(1\dots N\), and for
each pair of cities \((i,j)\) with \(i there either exists a single direct
flight from \(i\) to \(j\) or not.

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

Problem credits: Benjamin Qi

제약

SCORING

  • Inputs 3-4: \(N\le 6\)
  • Inputs 5-12: \(N\le 100\)
  • Inputs 13-22: No additional constraints.

Problem credits: Benjamin Qi

입력 형식

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
출력
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
출력
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}\).

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2023-2024 > December > Gold

태그

평가 및 의견

Flight Routes

개요
출제자 난이도 Gold I 골드 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Flight Routes

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8