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

10617번 - Magnetos 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB36231555.556%

문제

This is year 2050 and the SETI Institute (Search for Extraterrestrial Intelligence Institute) has recently decoded an alien message from Magneto Universe. Magnetos are offering earthlings with StarGate technology that can enable us to travel faster than the speed of light hence making intergalactic travel a reality. But before handing over the technology the Magnetos want to make sure that earthlings are smart enough to be worthy of the StarGate technology. So, in their message they've asked us to solve the following problem.

One component of a StarGate is a straight line that is made up of Magneto magnets. Unlike Earth's magnets, a magnet from Magneto Universe:

  • Has two opposite ends but each end can carry 1 out of 25 polarities.
  • Both ends of a magnet may carry the same polarity.
  • Identical polarities attract each other. Mismatching polarities also attract each other but will destroy the magnet on contact.

The figure below shows a segment of the valid magnetic arrangement that could be part of a StarGate.

Magnetos have sent a few random configurations of magnets and are asking if the magnets can be arranged in a straight line where first and the last end of the line have the same polarity.

Your task is to help SETI solve this problem.

입력

The input consists of multiple test cases. The first line of input is the number of test cases N (1≤N≤100). The first line of each test configuration contains an integer M (1≤M≤1000) specifying the number of magnets in the configuration. Each of the next M lines contains two integers describing the polarities of the magnet. Polarities are represented by integers ranging from 1 to 25.

출력

For each test configuration in the input first, output “Case #n: ” where n is the test configuration number, followed by “Yes” if the magnets can be arranged in the desired order and “No” otherwise.

제한

예제 입력 1

2
5
1 2
2 3
3 4
4 5
5 6
5
2 1
2 2
3 4
3 1
2 4

예제 출력 1

Case #1: No
Case #2: Yes

힌트

출처

ICPC > Regionals > Asia West Continent > Pakistan > Asia Lahore Regional 2014 2번

  • 데이터를 추가한 사람: doju
(追記) (追記ここまで)

출처

대학교 대회

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

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