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

27421번 - Make a Loop 다국어

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

문제

Taro is playing with a set of toy rail tracks. All of the tracks are arc-shaped with a right central angle (an angle of 90 degrees), but with many different radii. He is trying to construct a single loop using all of them. Here, a set of tracks is said to form a single loop when both ends of all the tracks are smoothly joined to some other track, and all the tracks are connected to all the other tracks directly or indirectly. Please tell Taro whether he can ever achieve that or not.

Tracks may be joined in an arbitrary order, but their directions are restricted by the directions of adjacent tracks, as they must be joined smoothly. For example, if you place a track so that a train enters eastward and turns 90 degrees northward, you must place the next track so that the train enters northward and turns 90 degrees to either east or west (Figure F.1). Tracks may cross or even overlap each other as elevated construction is possible.

Figure F.1. Example of smoothly joining tracks

입력

The input consists of a single test case in the following format.

$n$

$r_1$ $\cdots$ $r_n$

$n$ represents the number of tracks, which is an even integer satisfying 4ドル ≤ n ≤ 100$. Each $r_i$ represents the radius of the $i$-th track, which is an integer satisfying 1ドル ≤ r_i ≤ 10000$.

출력

If it is possible to construct a single loop using all of the tracks, print Yes; otherwise, print No.

제한

예제 입력 1

4
1 1 1 1

예제 출력 1

Yes

예제 입력 2

6
1 3 1 3 1 3

예제 출력 2

Yes

예제 입력 3

6
2 2 1 1 1 1

예제 출력 3

No

예제 입력 4

8
99 98 15 10 10 5 2 1

예제 출력 4

Yes

힌트

Possible loops for the sample inputs 1, 2, and 4 are depicted in the following figures.

(a) Sample 1 (b) Sample 2 (c) Sample 4

Figure F.2. Possible loops for the sample inputs

출처

ICPC > Regionals > Asia Pacific > Japan > ICPC 2022 Asia Yokohama Regional F번

Camp > Petrozavodsk Programming Camp > Summer 2023 > Day 1: Starting Contest A번

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

출처

대학교 대회

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

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