UVa 11498 Division of Nlogonia (water ver.)

11498 - Division of Nlogonia

Time limit: 1.000 seconds

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2493

The Problem

After centuries of hostilities and skirmishes between the four nations living in the land generally known as Nlogonia, and years of negotiations involving diplomats, politicians and the armed forces of all interested parties, with mediation by UN, NATO, G7 and SBC, it was at last agreed by all the way to end the dispute, dividing the land into four independent territories.

It was agreed that one point, called division point, with coordinates established in the negotiations, would define the country division, in the following way. Two lines, both containing the division point, one in the North-South direction and one in the East-West direction, would be drawn on the map, dividing the land into four new countries. Starting from the Western-most, Northern-most quadrant, in clockwise direction, the new countries will be called Northwestern Nlogonia, Northeastern Nlogonia, Southeastern Nlogonia and Southwestern Nlogonia.

The UN determined that a page in the Internet should exist so that the inhabitants could check in which of the countries their homes are. You have been hired to help implementing the system.

The Input

The input contains several test cases. The first line of a test case contains one integer K indicating the number of queries that will be made (0 < K ≤ 103). The second line of a test case contains two integers Nand M representing the coordinates of the division point (-104 < N, M < 104). Each of the K following lines contains two integers X and Y representing the coordinates of a residence (-104 ≤ X, Y ≤ 104).

The end of input is indicated by a line containing only the number zero.

The Output

For each test case in the input your program must print one line containing:

  • the word divisa (means border in Portuguese) if the residence is on one of the border lines (North-South or East-West);
  • NO (means NW in Portuguese) if the residence is in Northwestern Nlogonia;
  • NE if the residence is in Northeastern Nlogonia;
  • SE if the residence is in Southeastern Nlogonia;
  • SO (means SW in Portuguese) if the residence is in Southwestern Nlogonia.

Sample Input

3
2 1
10 10
-10 1
0 33
4
-1000 -1000
-1000 -1000
0 0
-2000 -10000
-999 -1001
0

Sample Output

NE
divisa
NO
divisa
NE
SO
SE

完整代码:

/*0.015s*/

#include <cstdio>

int main()
{
	int k, N, M, x, y;
	while (scanf("%d", &k), k)
	{
		scanf("%d%d", &N, &M);
		while (k--)
		{
			scanf("%d%d", &x, &y);
			if (x == N || y == M) puts("divisa");
			else if (x > N && y > M) puts("NE");
			else if (x < N && y > M) puts("NO");
			else if (x > N && y < M) puts("SE");
			else puts("SO");
		}
	}
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值