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

13996번 - Hard Refactoring 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB153635439.706%

문제

Helen had come upon a piece of code that uses a lot of “magical constants”. She found a logical expression that checks if an integer x belongs to a certain set of ranges, like the one shown below:

x >= 5 && x <= 10 || 
x >= 7 && x <= 20 || 
x <= 2 || 
x >= 21 && x <= 25 || 
x >= 8 && x <= 10 || 
x >= 100 

Helen does not like “magical constants”, so she decided to refactor this expression and all similar ones in such a way, that the refactored expression still has the same Boolean result for all integers x, but it uses as few integer constants in its text as possible.

Integers in this problem, including integer x, come from the range of all signed 16 bit integers starting from −215 (−32 768) to 215 − 1 (32 767) inclusive.

입력

The input file contains at most 1000 lines. Each line consists of either one comparison or two comparisons separated by logical and operator “&&”. Each comparison starts with “x”, followed by greater-or-equals operator “>=” or less-or-equals operator “<=”, followed by an integer constant. When two comparisons are in the same line, the first one is always greater-or-equals, followed by less-or-equals.

All lines, but the last one, are terminated by logical or operator “||”. All tokens in a line are separated by a single space and there are no trailing or leading spaces.

출력

Write the refactored expression to the output file in the same format as in the input. You can arrange lines in any order, as long as the resulting expression has the right format, produces the same Boolean result on all integers x, and contains the minimal possible number of integer constants in its text. Numbers must be formatted without leading zeros and there must be precisely one space between tokens on a line.

Write a single line with the word “true” if the expression is true on all integers. Write a single line with the word “false” if the expression is false on all integers.

제한

예제 입력 1

x >= 5 && x <= 10 ||
x >= 7 && x <= 20 ||
x <= 2 ||
x >= 21 && x <= 25 ||
x >= 8 && x <= 10 ||
x >= 100

예제 출력 1

x <= 2 ||
x >= 5 && x <= 25 ||
x >= 100

예제 입력 2

x >= 10 && x <= 0

예제 출력 2

false

예제 입력 3

x <= 10 ||
x >= 0

예제 출력 3

true

예제 입력 4

x >= -32768

예제 출력 4

true

힌트

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > NEERC 2016 H번

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

출처

대학교 대회

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

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