Computer Programming Contest Preparation

ToolBox - Source for: 109/10963/a.c



/home/toolbox/public_html/solutions/109/10963/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 <stdlib.h>
    7 #include <math.h>
    8 #include <stdint.h>
    9 #include <ctype.h>
   10 
   11 #define TRUE  (1 == 1)
   12 #define FALSE (1 != 1)
   13 
   14 #define DEBUG if (FALSE)
   15 
   16 /* fprintf(stderr, "functionName: message", varslist); */
   17 
   18 /*
   19  *  Author: Isaac Traxler
   20  *    Date: 2025-04-30
   21  * Purpose: fun
   22  * Problem: 10963 - The Swallowing Ground
   23  */
   24 
   25 /*
   26  * This template reads data a specified number of times.
   27  */
   28 
   29 int numberOfTimes;
   30 int valid;
   31 int numCols;
   32 int ya;
   33 int yb;
   34 int diff;
   35 
   36 /* the difference between ya and yb must be consistent for the gap to be closed */
   37 
   38 void init()
   39 {
   40     /* FUNCTION init */
   41     scanf("%d ", &numberOfTimes);
   42 } /* FUNCTION init */
   43 
   44 void dump()
   45 {
   46     /* FUNCTION dump */
   47 } /* FUNCTION dump */
   48 
   49 void getInput()
   50 {
   51     /* FUNCTION getInput */
   52     int i;
   53 
   54     valid = TRUE;
   55     scanf(" %d ", &numCols);
   56     scanf(" %d %d ", &ya, &yb);
   57     diff = ya - yb;
   58     for (i=1; i<numCols; i++)
   59         {
   60             /* for 2 to last rows */
   61             scanf(" %d %d ", &ya, &yb);
   62             valid = valid && (diff == (ya - yb));
   63         } /* for 2 to last rows */
   64 } /* FUNCTION getInput */
   65 
   66 void process()
   67 {
   68     /* FUNCTION process */
   69     if (valid)
   70         {
   71             printf("yes\n");
   72         }
   73     else
   74         {
   75             printf("no\n");
   76         }
   77 } /* FUNCTION process */
   78 
   79 int main()
   80 {
   81     /* main */
   82     int i;
   83 
   84     init();
   85     for (i=0; i<numberOfTimes; i++)
   86         {
   87             /* while */
   88             if (0 != i)
   89                 {
   90                     printf("\n");    /* handle blank line between cases */
   91                 }
   92             getInput();
   93             process();
   94         } /* while */
   95 
   96     return EXIT_SUCCESS;
   97 } /* main */
   98 
   99