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

6060번 - Wheel Rotation 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB29323820882.540%

문제

Farmer John has an old-time thresher (wheat harvester) that requires belts to be installed on various gears to turn the parts. The engine drives pulley 1 in a clockwise direction which attaches via a belt to pulley 2. Pulley 2 attaches via a belt to pulley 3 and so on through a total of N (2 <= N <= 1,000) pulleys (and N-1 belts).

The diagram above depicts the two ways a belt can be installed between two gears. In this illustration, pulley 1's belt directly drives pulley 2 (a 'straight' connection) and thus they will rotate in the same direction. Pulley 3 drives pulley 4 via a 'crossed belt' that reverses the direction of the rotation.

Given a list of the belt types that connect the pulleys along with the fact that pulley 1 is driven in a clockwise direction by the engine, determine the drive direction of pulley N. Each belt is described by three integers:

  • S_i -- the driving (source) pulley
  • D_i -- the driven (destination) pulley
  • C_i -- the connection type (0=straight, 1=crossed)

Unfortunately, FJ lists the belts in random order.

By way of example, consider the illustration below. N = 4, and pulley 1 is driven clockwise by the thresher engine. Straight belts drive pulley 2 and then pulley 3, so they rotate clockwise. The crosswise belt reverses the rotation direction so pulley 4 (pulley N) rotates counterclockwise.

입력

  • Line 1: A single integer: N
  • Lines 2..N: Each line describes a belt with three integers: S_i, D_i, and C_i

출력

  • Line 1: A single integer that is the rotation direction for pulley N (0=clockwise, 1=counterclockwise)

제한

예제 입력 1

4
2 3 0
3 4 1
1 2 0

예제 출력 1

1

힌트

출처

Olympiad > USA Computing Olympiad > 2008-2009 Season > USACO October 2008 Contest > Gold 5번

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

출처

대학교 대회

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

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