시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 24 7 4 19.048%

문제

여러분은 양팔 저울 하나와 동전 12개(1, 2, ..., 12 의 번호)를 가지고 있는데, 그 중 하나는 모조품입니다. 모조품은 다른 동전보다 가볍거나 무겁습니다. 

양팔 저울로 세 번 측정하여 모조품을 찾고,  그것이 무거운지 가벼운지 밝히는 프로그램을 작성하세요.

입력

무게를 측정한 결과 데이터가 아래와 같은 형식의 표준 입력으로 주어지게 됩니다.

A B C D x E F G H

A, B, C, D, E, F, G, H 는 서로 다른 8 개의 동전들의 숫자이고, x 는 <, >, =  중에 하나입니다. 다음과 같은 의미를 지닙니다.

  • < : A, B, C, D 의 총합은 E, F, G, H 의 총합보다 작다
  • > : A, B, C, D 의 총합은 E, F, G, H 의 총합보다 크다
  • = : A, B, C, D 의 총합은 E, F, G, H 의 총합과 같다

출력

프로그램은 표준출력에 모조품의 번호를 출력하고, 다른 동전보다 무거운 경우에는 + 를, 가벼운 경우에는 - 를 이어서 출력합니다.

세 번의 측정 데이터가 모순되는 경우에는 "impossible" 을 출력해야 합니다.

데이터가 모순되지는 않지만 모조품의 번호를 알아내기에 불충분하거나, 무거운지 가벼운지 알 수 없는 경우에는 "indefinite" 를 출력해야 합니다.

예제 입력 1

1 2 3 10 > 4 5 6 11
1 2 3 11 > 7 8 9 10
1 4 7 10 < 2 5 8 12

예제 출력 1

2+

예제 입력 2

1 4 6 10 < 5 7 9 12
2 5 4 11 > 6 8 7 10
3 6 5 12 < 4 9 8 11

예제 출력 2

6-

예제 입력 3

1 2 3 4 < 5 6 7 8
5 6 7 8 < 9 10 11 12
9 10 11 12 < 1 2 3 4

예제 출력 3

impossible

예제 입력 4

4 8 10 11 = 1 2 5 7
2 4 7 12 = 8 9 10 11
3 7 10 11 > 6 8 9 12

예제 출력 4

indefinite
W3sicHJvYmxlbV9pZCI6IjMzNjMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIzZDlcdWM4MD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