// [4/13/2014 Sjm] /* 关键: 寻找 左右区间,判断此区间是否合理。 */#include <iostream> #include <cstdio> #include <cstdlib> #include <string> #include <algorithm> using namespace std; const int MAX = 2000000000, MIN = -2000000000; int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int n, lef = MIN, rig = MAX, temp; string str; char c; scanf("%d", &n); while (n--) { cin >> str; scanf("%d %c", &temp, &c); if ('N' == c) { if (">" == str) str = "<="; else { if ("<" == str) str = ">="; else { if ("<=" == str) str = ">"; else str = "<"; } } } if (">" == str) lef = max(lef, temp + 1); else { if ("<" == str) rig = min(rig, temp - 1); else { if (">=" == str) lef = max(lef, temp); else rig = min(rig, temp); } } } if (lef > rig) printf("Impossible\n"); else printf("%d\n", lef); return 0; }
模拟 之 Codeforces 416A
最新推荐文章于 2022-04-08 10:57:51 发布