/home/toolbox/public_html/solutions/114/11498/a.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <stdint.h>
7 #include <math.h>
8 #include <stdlib.h>
9
10 #define TRUE (1 == 1)
11 #define FALSE (1 != 1)
12
13 #define DEBUG if (FALSE)
14
15 /*
16 * Author: Isaac Traxler
17 * Date: 2015-03-23
18 * Purpose:
19 * Problem: 11498
20 */
21
22 /*
23 * This template reads data until a terminating value is reached.
24 */
25
26 int k; /* number of queries */
27 int dx; /* x value of divisa */
28 int dy; /* y value of divisa */
29 /* 0 1 2 3 4 */
30 char where[5][10] = {"SO", "SE", "NO", "NE", "divisa"};
31
32
33 void init()
34 {
35 /* FUNCTION init */
36 int i;
37
38 for (i=0; i<5; i++)
39 printf("%d: [%s]\n", i, where[i]);
40 } /* FUNCTION init */
41
42 void dump()
43 {
44 /* FUNCTION dump */
45 } /* FUNCTION dump */
46
47 int getInput()
48 {
49 /* FUNCTION getInput */
50 int dataReadFlag = TRUE;
51
52 scanf(" %d ", &k);
53 if (0<k)
54 {
55 /* we have work to do */
56 scanf(" %d %d ", &dx, &dy);
57 } /* we have work to do */
58 else
59 {
60 /* time to quit */
61 dataReadFlag = FALSE;
62 } /* time to quit */
63 return (dataReadFlag);
64 } /* FUNCTION getInput */
65
66 int check(int x, int y)
67 {
68 /* FUNCTION check */
69 int ret = 0;
70
71 if ((x == dx) || (y == dy))
72 {
73 ret = 4;
74 }
75 else
76 {
77 /* not on a border */
78 if (x > dx)
79 {
80 /* east */
81 ret = 1;
82 } /* east */
83 if (y > dy)
84 {
85 /* north */
86 ret = ret + 2;
87 } /* north */
88 } /* not on a border */
89 return ret;
90 } /* FUNCTION check */
91
92 void process()
93 {
94 /* FUNCTION process */
95 int i;
96 int qx;
97 int qy;
98 int tmp;
99
100 for (i=0; i<k; i++)
101 {
102 /* process each query */
103 scanf(" %d %d ", &qx, &qy);
104 tmp = check(qx, qy);
105 DEBUG printf("tmp = %d ", tmp);
106 printf("%s\n", where[tmp]);
107 } /* process each query */
108 } /* FUNCTION process */
109
110 int main()
111 {
112 /* main */
113 int moreToDo;
114
115 moreToDo = getInput();
116 while (moreToDo)
117 {
118 /* while */
119 process();
120 moreToDo = getInput();
121 } /* while */
122
123 return EXIT_SUCCESS;
124 } /* main */
125