codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

416A.md (2032B)


      1 Source: https://codeforces.com/problemset/problem/416/A
      2 
      3 A. Guess a number!
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.
     22 
     23 The rules are simple. The host thinks of an integer *y* and the participants guess it by asking questions to the host. There are four types of acceptable questions:
     24 
     25 * Is it true that *y* is strictly larger than number *x*?
     26 * Is it true that *y* is strictly smaller than number *x*?
     27 * Is it true that *y* is larger than or equal to number *x*?
     28 * Is it true that *y* is smaller than or equal to number *x*?
     29 
     30 On each question the host answers truthfully, "yes" or "no".
     31 
     32 Given the sequence of questions and answers, find any integer value of *y* that meets the criteria of all answers. If there isn't such value, print "Impossible".
     33 
     34 Input
     35 
     36 The first line of the input contains a single integer *n* (1 ≤ *n* ≤ 10000) — the number of questions (and answers). Next *n* lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:
     37 
     38 * ">" (for the first type queries),
     39 * "<" (for the second type queries),
     40 * ">=" (for the third type queries),
     41 * "<=" (for the fourth type queries).
     42 
     43 All values of *x* are integer and meet the inequation  - 109 ≤ *x* ≤ 109. The answer is an English letter "Y" (for "yes") or "N" (for "no").
     44 
     45 Consequtive elements in lines are separated by a single space.
     46 
     47 Output
     48 
     49 Print any of such integers *y*, that the answers to all the queries are correct. The printed number *y* must meet the inequation  - 2·109 ≤ *y* ≤ 2·109. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).
     50 
     51 Examples
     52 
     53 Input
     54 
     55 ```
     56 4  
     57 >= 1 Y  
     58 < 3 N  
     59 <= -3 N  
     60 > 55 N
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 17
     67 ```
     68 
     69 Input
     70 
     71 ```
     72 2  
     73 > 100 Y  
     74 < -100 Y
     75 ```
     76 
     77 Output
     78 
     79 ```
     80 Impossible
     81 ```