ens-ulm-1

google hashcode 2014 source for team ens-ulm-1
git clone https://a3nm.net/git/ens-ulm-1/
Log | Files | Refs

mkdiff.cpp (807B)


      1 
      2 const int ROWS = 716;
      3 const int COLS = 1522;
      4 
      5 #include <cstdio>
      6 
      7 bool orig[ROWS][COLS];
      8 bool fill[ROWS][COLS];
      9 
     10 void read(char *filename, bool x[ROWS][COLS]) {
     11 
     12   FILE *fp = fopen(filename, "r");
     13   
     14   fscanf(fp, "%*d%*d");
     15 
     16   for (int r = 0; r < ROWS; r++)
     17     {
     18     for (int c = 0; c < COLS; c++)
     19       {
     20         char C;
     21         do
     22           C = fgetc(fp);
     23         while (C != '#' && C != '.');
     24         x[r][c] = (C == '#');
     25       }
     26     //        printf("%d\n", r);
     27     }
     28 
     29 
     30   fclose(fp);
     31 
     32 }
     33 
     34 int main(int argc, char *argv[]) {
     35 
     36   if (argc < 2) {
     37     puts("2 ARGS");
     38     return 0;
     39   }
     40 
     41   read(argv[1], orig);
     42   read(argv[2], fill);
     43 
     44   for (int r = 0; r < ROWS; r++)
     45     for (int c = 0; c < COLS; c++)
     46       if (fill[r][c] && !orig[r][c]) {
     47         printf("ERASECELL %d %d\n", r, c);
     48       }
     49 
     50   return 0;
     51 }