/home/toolbox/public_html/solutions/109/10919/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 #include <ctype.h>
10
11 #define TRUE (1 == 1)
12 #define FALSE (1 != 1)
13
14 #define DEBUG if (FALSE)
15
16 /*
17 * Author: Isaac Traxler
18 * Date: 2022-10-25
19 * Purpose: fun
20 * Problem: 10919 - prerequisites
21 */
22
23 /*
24 * This template reads data until a terminating value is reached.
25 */
26
27 #define MAX_TAKING 10005
28
29 #define TAKING 1
30 #define NOT_TAKING 0
31
32
33
34 int k; /* number of course selections */
35 int m; /* number of classes */
36 int taking[MAX_TAKING];
37
38 void init()
39 {
40 /* FUNCTION init */
41 } /* FUNCTION init */
42
43 void dump()
44 {
45 /* FUNCTION dump */
46 } /* FUNCTION dump */
47
48 int getInput()
49 {
50 /* FUNCTION getInput */
51 int dataReadFlag;
52 int i;
53 int tmp;
54
55 scanf(" %d ", &k);
56 dataReadFlag = (0 < k);
57 if (dataReadFlag)
58 {
59 /* get rest of class list */
60 scanf(" %d ", &m);
61 for (i=0; MAX_TAKING>i; i++)
62 {
63 taking[i] = NOT_TAKING;
64 }
65 for (i=0; k>i; i++)
66 {
67 /* get each required class */
68 scanf(" %d ", &tmp);
69 taking[tmp] = TAKING;
70 } /* get each required class */
71 } /* get rest of class list */
72 return (dataReadFlag);
73 } /* FUNCTION getInput */
74
75 void process()
76 {
77 /* FUNCTION process */
78 int graduate = TRUE;
79 int cnt;
80 int req;
81 int i;
82 int j;
83 int tot;
84 int tmp;
85
86 for (i=0; m>i; i++)
87 {
88 /* for each requirement */
89 scanf(" %d %d ", &cnt, &req);
90 tot = 0;
91 for (j=0; cnt>j; j++)
92 {
93 /* get each class */
94 scanf(" %d ", &tmp);
95 tot = tot + taking[tmp];
96 } /* get each class */
97 graduate = graduate && (tot >= req);
98 } /* for each requirement */
99 if (graduate)
100 {
101 /* yeah */
102 printf("yes\n");
103 } /* yeah */
104 else
105 {
106 /* bummer */
107 printf("no\n");
108 } /* bummer */
109 } /* FUNCTION process */
110
111 int main()
112 {
113 /* main */
114 int moreToDo;
115
116 init();
117 moreToDo = getInput();
118 while (moreToDo)
119 {
120 /* while */
121 process();
122 moreToDo = getInput();
123 } /* while */
124
125 return EXIT_SUCCESS;
126 } /* main */
127