当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2883:Points

题目描述
Let p1, p2, . . . , pn be n points on the plane. We have m rules of form pi rel pj , each inform us that the relation rel holds among the locations of points pi and pj on the plane. For example, “pi NE pj” indicates that point pj is located NorthEast of point pi. There are eight different relations {N, E, S, W, NE, NW, SE, SW}, corresponding to the eight directions on the plane. Let (xi, yi) and (xj , yj) be the coordinates of pi, and pj respectively. Then pi rel pj exactly means one of the following, depending on the value of rel:
  1. N stands for North. This means that xj = xi and yj > yi,

  2. E stands for East. This means that xj > xi and yj = yi,

  3. S stands for South. This means that xj = xi and yj < yi,

  4. W stands for West. This means that xj < xi and yj = yi,

  5. NE stands for NorthEast. This means that xj > xi and yj > yi,

  6. NW stands for NorthWest. This means that xj < xi and yj > yi,

  7. SE stands for SouthEast. This means that xj > xi and yj < yi, and

  8. SW stands for SouthWest. This means that xj < xi and yj < yi.
The problem is to determine whether it possible to locate p1, p2, . . . , pn on the plane so that all
given rules are satisfied.
输入解释
The first line of the input contains a single integer t (1 ≤ t ≤ 20) which is the number of test cases in the input. The first line of each test case contains two integers n (2 ≤ n ≤ 500) which is the number of points and m (1 ≤ m ≤ 10000) which is the number of rules. In each of the following m lines, there is one rule of the form i rel j which means that pi has relation rel with pj.
输出解释
The output contains one line per each test case containing one of the words POSSIBLE or IMPOSSIBLE indicating if the set of points in the test case can be located on the plane according to the given rules.
输入样例
2
3 2
1 N 2
2 N 1
6 6
1 E 2
1 E 3
2 N 4
3 NW 5
4 SW 6
6 NE 5
输出样例
IMPOSSIBLE
POSSIBLE

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Tehran 2004

源链接: POJ-2883

最后修改于 2020-10-29T06:46:42+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536