题目链接:http://codeforces.com/contest/416/problem/A
题目分析:夹逼法求y
代码:#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
int n,x,l,r;
char tag[5],yn[5];
while(scanf("%d",&n)!=EOF)
{
r =2*1000000000;
l=-r;
for(int i=1; i<=n; i++)
{
scanf("%s%d%s",tag,&x,yn);
if(strcmp(tag,">=")==0)
{
if(yn[0]=='N')
{
if(x-1<r)
r=x-1;
}
else
{
if(x>l)
l=x;
}
}
else if(strcmp(tag,"<")==0)
{
if(yn[0]=='N')
{
if(x>l)
l=x;
}
else
{
if(x-1<r)
r=x-1;
}
}
else if(strcmp(tag,">")==0)
{
if(yn[0]=='N')
{
if(x<r)
r=x;
}
else
{
if(x+1>l)
l=x+1;
}
}
else if(strcmp(tag,"<=")==0)
{
if(yn[0]=='N')
{
if(x+1>l)
l=x+1;
}
else
{
if(x<r)
r=x;
}
}
}
if(l>r)
printf("Impossible\n");
else printf("%d\n",l);
}
return 0;
}