Computer Programming Contest Preparation

ToolBox - Source for: 101/10141/b.c



/home/toolbox/public_html/solutions/101/10141/b.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: 2025-04-15
   19  * Purpose: fun
   20  * Problem: 10141 - Request for Proposal
   21  */
   22 
   23 /*
   24  * This template reads data until a terminating value is reached.
   25  */
   26 
   27 /* started assuming that reqwould need to be searched. Actually it is all irrelevant:
   28  * for each met requirement, the name of the requirement, each on a separate line. All
   29  * requirements are from the RFP requirement list, and no requirements are duplicated.
   30  *
   31  *   So the requirement count is all that is needed --
   32  *   so I abandoned this code
   33  */
   34 
   35 
   36 #define MAX_RFPS 1004
   37 #define MAX_LINE 84
   38 
   39 int numReq;
   40 char req[MAX_RFPS][MAX_LINE];
   41 int numRfps;
   42 char rfp[MAX_RFPS][MAX_LINE];
   43 double cost[MAX_RFPS];
   44 int compliance[MAX_RFPS];
   45 char line[MAX_LINE];
   46 
   47 void init()
   48 {
   49     /* FUNCTION init */
   50 } /* FUNCTION init */
   51 
   52 void dump()
   53 {
   54     /* FUNCTION dump */
   55 } /* FUNCTION dump */
   56 
   57 void optionFound()
   58 {
   59     /* FUNCTION optionFound */
   60     int found = TRUE;
   61 
   62     /* code goes here to search to see if option found */
   63     /* could an option be listed twice? */
   64     return found;
   65 } /* FUNCTION optionFound */
   66 
   67 int getInput()
   68 {
   69     /* FUNCTION getInput */
   70     int dataReadFlag;
   71     int i;
   72     int j;
   73     int tmpCnt;
   74 
   75     scanf(" %d %d ", &numReq, &numRfps);
   76     dataReadFlag = (0 != numReq) || (0 != numRfps);
   77     if (dataReadFlag)
   78         {
   79             /* actually get data */
   80             /* get all requests */
   81             for (i=0; i<numReq; i++)
   82                 {
   83                     /* get each requirement */
   84                     fgets(req[i], MAX_LINE, stdin);
   85                     req[strlen(req[i])-1] = 0; /* remove newline */
   86                 } /* get each requirement */
   87             /* sort of req could go here */
   88             /* get rfp data */
   89             for (i=0; i<numRfps; i++)
   90                 {
   91                     /* get each RFP */
   92                     fgets(rfp[i], MAX_LINE, stdin);
   93                     req[strlen(rfp[i])-1] = 0; /* remove newline */
   94                     compliance[i] = 0;
   95                     scanf(" %lf %d ", &cost[i], &tmpCnt);
   96                     for (j=0; j<tmpCnt; j++)
   97                         {
   98                             /* for each option */
   99                             fgets(line, MAX_LINE, stdin);
  100                             line[strlen(line)-1] = 0; /* remove newline */
  101                             if (optionFound(line))
  102                                 {
  103                                     /* add another match */
  104                                     compliance[i] += 1;
  105                                 } /* add another match */
  106                         } /* for each option */
  107                     compliance[i] = compliance[i] / numReq;
  108                 } /* get each RFP */
  109         } /* actually get data */
  110     return (dataReadFlag);
  111 } /* FUNCTION getInput */
  112 
  113 void process()
  114 {
  115     /* FUNCTION process */
  116 } /* FUNCTION process */
  117 
  118 int main()
  119 {
  120     /* main */
  121     int moreToDo;
  122 
  123     init();
  124     moreToDo = getInput();
  125     while (moreToDo)
  126         {
  127             /* while */
  128             process();
  129             moreToDo = getInput();
  130         } /* while */
  131 
  132     return EXIT_SUCCESS;
  133 } /* main */
  134