/home/toolbox/public_html/solutions/103/10324/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 /*
17 * Author: Isaac Traxler
18 * Date: 2016-04-29
19 * Purpose: fun
20 * Problem: 10324 - Zeroes and Ones
21 */
22
23 /*
24 * This template reads lines of data at a time until end of file.
25 */
26
27 #define MAX_LINE 1000011
28
29 char line[MAX_LINE];
30 int queries;
31 char answer[2][4] = { "Yes", "No" };
32
33 void init()
34 {
35 /* FUNCTION init */
36 } /* FUNCTION init */
37
38 void dump()
39 {
40 /* FUNCTION dump */
41 } /* FUNCTION dump */
42
43 int getInput()
44 {
45 /* FUNCTION getInput */
46 int dataReadFlag;
47
48 fgets(line, MAX_LINE, stdin);
49 if (feof(stdin))
50 dataReadFlag = FALSE;
51 else
52 {
53 /* something to read */
54 dataReadFlag = TRUE;
55 line[strlen(line)-1] = 0;
56 scanf(" %d ", &queries);
57 } /* something to read */
58 return (dataReadFlag);
59 } /* FUNCTION getInput */
60
61 int tst(int a, int b)
62 {
63 /* FUNCTION tst */
64 int toReturn = TRUE;
65 int i;
66
67 if (a != b)
68 {
69 /* must check */
70 for (i=a; (i<=b) && toReturn; i++)
71 {
72 /* start comparing */
73 DEBUG printf("line[%d] = %c line[%d] = %c\n", a, line[a], i, line[i]);
74 toReturn = line[a] == line[i];
75 } /* start comparing */
76 } /* must check */
77 if (toReturn)
78 toReturn = 0;
79 else
80 toReturn = 1;
81 return toReturn;
82 } /* FUNCTION tst */
83
84 void process()
85 {
86 /* FUNCTION process */
87 int i;
88 int a;
89 int b;
90 int c;
91
92 for (i=0; i<queries; i++)
93 {
94 /* for each wuery */
95 scanf(" %d %d ", &a, &b);
96 if (a > b)
97 {
98 c = a;
99 a = b;
100 b = c;
101 }
102 DEBUG printf(" %d %d \n", a, b);
103 c = tst(a, b);
104 DEBUG printf("%d ", c);
105 DEBUG printf("%d %d ", queries, i);
106 printf("%s\n", answer[c]);
107 } /* for each wuery */
108 } /* FUNCTION process */
109
110 int main()
111 {
112 /* main */
113 int moreToDo;
114 int cse = 1;
115
116 init();
117 moreToDo = getInput();
118 while (moreToDo)
119 {
120 /* while */
121 printf("Case %d:\n", cse);
122 cse++;
123 process();
124 moreToDo = getInput();
125 } /* while */
126
127 return EXIT_SUCCESS;
128 } /* main */
129