/home/toolbox/public_html/solutions/119/11926/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: 2016-8-24
18 * Purpose: fun
19 * Problem: 11926 Multitasking
20 */
21
22 /*
23 * This template reads data until a terminating value is reached.
24 */
25
26 #define MAX 1000001
27 int a[MAX*2];
28
29 int m;
30 int n;
31 int overlap;
32
33 void init()
34 {
35 /* FUNCTION init */
36 int i;
37
38 for (i=0; i<MAX; i++)
39 {
40 /* for i */
41 a[i] = 0;
42 } /* for i */
43 } /* FUNCTION init */
44
45 void dump()
46 {
47 /* FUNCTION dump */
48 } /* FUNCTION dump */
49
50 int getInput()
51 {
52 /* FUNCTION getInput */
53 int dataReadFlag;
54
55 scanf(" %d %d ", &n, &m);
56 dataReadFlag = ((0 != m) || (0 != n));
57 return (dataReadFlag);
58 } /* FUNCTION getInput */
59
60 void doTask(int start, int stop)
61 {
62 /* FUNCTION doTask */
63 int j;
64 int tmp;
65
66 tmp = stop;
67 if (tmp >= MAX)
68 {
69 tmp = MAX;
70 }
71 for (j=start; j<tmp; j++)
72 {
73 /* for each time between */
74 overlap = overlap || (0 != a[j]);
75 a[j] = 1;
76 } /* for each time between */
77 } /* FUNCTION doTask */
78
79 void process()
80 {
81 /* FUNCTION process */
82 int i;
83 int j;
84 int start;
85 int stop;
86 int interval;
87
88 overlap = FALSE;
89 for (i=0; i<n; i++)
90 {
91 /* process each one time task */
92 scanf(" %d %d ", &start, &stop);
93 doTask(start, stop);
94 } /* process each one time task */
95 for (i=0; i<m; i++)
96 {
97 /* process each repeat task */
98 scanf(" %d %d %d ", &start, &stop, &interval);
99 stop = stop - start;
100 for (j=start; j<MAX; j=j+interval)
101 {
102 /* for each interval */
103 doTask(j, j+stop);
104 } /* for each interval */
105 } /* process each repeat task */
106 if (! overlap)
107 {
108 printf("NO ");
109 }
110 printf("CONFLICT\n");
111 } /* FUNCTION process */
112
113 int main()
114 {
115 /* main */
116 int moreToDo;
117
118 moreToDo = getInput();
119 while (moreToDo)
120 {
121 /* while */
122 init();
123 process();
124 moreToDo = getInput();
125 } /* while */
126
127 return EXIT_SUCCESS;
128 } /* main */
129