Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit Status

Description

A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.

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:

  • Is it true that y is strictly larger than number x?
  • Is it true that y is strictly smaller than number x?
  • Is it true that y is larger than or equal to number x?
  • Is it true that y is smaller than or equal to number x?

On each question the host answers truthfully, "yes" or "no".

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".

Input

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:

  • ">" (for the first type queries),
  • "<" (for the second type queries),
  • ">=" (for the third type queries),
  • "<=" (for the fourth type queries).

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").

Consequtive elements in lines are separated by a single space.

Output

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).

Sample Input

Input
4
>= 1 Y
< 3 N
<= -3 N
> 55 N
Output
17
Input
2
> 100 Y
< -100 Y
Output
Impossible

Source

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int f[]; int main()
{
int n,min0=-,max0=;
cin>>n;
for(int i=;i<n;i++)
{
char x[],an;int num;
cin>>x>>num>>an;
if(an=='Y'&&x[]=='>')
{
if(x[]=='=')
min0=max(min0,num);
else min0=max(min0,num+);
}
else if(an=='N'&&x[]=='>')
{
if(x[]=='=')
max0=min(max0,num-);
else max0=min(max0,num);
}
else if(an=='Y'&&x[]=='<')
{
if(x[]=='=')
max0=min(max0,num);
else max0=min(max0,num-);
}
else if(an=='N'&&x[]=='<')
{
if(x[]=='=')
min0=max(min0,num+);
else min0=max(min0,num);
}
// cout<<max0<<' '<<min0<<endl;
}
if(max0>=min0)
cout<<min0<<endl;
else cout<<"Impossible"<<endl;
return ;
}

CodeForces - 416A (判断大于小于等于 模拟题)的更多相关文章

  1. CodeForces - 427B (模拟题)

    Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Sub ...

  2. Codeforces Beta Round #3 C. Tic-tac-toe 模拟题

    C. Tic-tac-toe 题目连接: http://www.codeforces.com/contest/3/problem/C Description Certainly, everyone i ...

  3. Educational Codeforces Round 2 A. Extract Numbers 模拟题

    A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...

  4. Codeforces 767B. The Queue 模拟题

    B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...

  5. Codeforces Beta Round #7 B. Memory Manager 模拟题

    B. Memory Manager 题目连接: http://www.codeforces.com/contest/7/problem/B Description There is little ti ...

  6. Codeforces Beta Round #5 B. Center Alignment 模拟题

    B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...

  7. Codeforces Gym 100269B Ballot Analyzing Device 模拟题

    Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election comm ...

  8. CSP复赛day2模拟题

    没错,我又爆零了.....先让我自闭一分钟.....so 当你忘记努力的时候,现实会用一记响亮的耳光告诉你东西南北在哪. 好了,现在重归正题: 全国信息学奥林匹克联赛(NOIP2014) 复赛模拟题 ...

  9. 全国信息学奥林匹克联赛 ( NOIP2014) 复赛 模拟题 Day1 长乐一中

    题目名称 正确答案  序列问题 长途旅行 英文名称 answer sequence travel 输入文件名 answer.in sequence.in travel.in 输出文件名 answer. ...

随机推荐

  1. 洛谷P1508 Likecloud-吃、吃、吃

    题目背景 问世间,青春期为何物? 答曰:“甲亢,甲亢,再甲亢:挨饿,挨饿,再挨饿!” 题目描述 正处在某一特定时期之中的李大水牛由于消化系统比较发达,最近一直处在饥饿的状态中.某日上课,正当他饿得头昏 ...

  2. Android——Canvas类的学习

    转:http://blog.sina.com.cn/s/blog_61ef49250100qw9x.html 今晚瞎折腾,闲着没事画了个机器人——android,浪费了一个晚上的时间.画这丫还真不容易 ...

  3. 轻量级应用开发之(06)Autolayout自动布局2

    一 Masonry 下载地址:https://github.com/SnapKit/Masonry

  4. MyEclipse------各种问题解决方法

    1.汉化后如何变为英文版:找到myeclipse.ini文件,改为:language=enlanguage=zh为中文 2.解决版本不匹配问题:http://blog.sina.com.cn/s/bl ...

  5. spark对于elasticsearch里的复杂类型支持

    IP,直接在case class里用string, 可以考虑先用其它程序生成相关的mapping,然后再去用spark填充数据

  6. 添加一个txt文件(例如在桌面),利用后台对文件写入内容

    string str = "今天天气好晴朗,处处好风光."; //需要将字符串转化成字节数组 byte[] buffer = Encoding.Default.GetBytes(s ...

  7. spring事务学习(转账案例)(二)

    四.通过springAop进行事务管理 继续从第一个无事务操作的项目中进行更改. 只修改applicationContext.xml配置文件,注意设置transaction引用 <?xml ve ...

  8. nl命令详解

    nl命令在linux系统中用来计算文件中行号.nl 可以将输出的文件内容自动的加上行号!其默认的结果与 cat -n 有点不太一样, nl 可以将行号做比较多的显示设计,包括位数与是否自动补齐 0 等 ...

  9. Memcached在windows下的安装于使用

    原文链接:http://blog.csdn.net/jjmaiz/article/details/7935672 有一点要注意的是,上文作者没有提及: 将php_memcached.dll放在ext文 ...

  10. WPF RichTextBox的使用总结

    RichTextBox内容模型 RichTextBox 支持基于块的内容模型. RichTextBox   的内容属性为 Blocks,这是 Paragraph 元素的集合Paragraph元素可包含 ...