ens-ulm-1

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

filler.cpp (794B)


      1 const int ROWS = 716;
      2 const int COLS = 1522;
      3 
      4 #include <cstdio>
      5 
      6 bool a[ROWS][COLS];
      7 
      8 int main(int argc, char *args[]) {
      9 
     10   scanf("%*d%*d");
     11 
     12   for (int r = 0; r < ROWS; r++)
     13     for (int c = 0; c < COLS; c++)
     14       {
     15         char C;
     16         do
     17           C = getchar();
     18         while (C != '#' && C != '.');
     19         a[r][c] = (C == '#');
     20       }
     21 
     22   for (int r = 1; r < ROWS-1; r++)
     23     for (int c = 1; c < COLS-1; c++) {
     24       if (a[r-1][c-1] && a[r-1][c] && a[r-1][c+1] && a[r][c-1] && a[r][c+1] && a[r+1][c-1] && a[r+1][c] && a[r+1][c+1] && !a[r][c])
     25         a[r][c] = true;
     26     }
     27 
     28   printf("%d %d\n", ROWS, COLS);
     29 
     30   for (int r = 0; r < ROWS; r++)
     31     {
     32       for (int c = 0; c < COLS; c++)
     33         {
     34           putchar(a[r][c] ? '#' : '.');
     35         }
     36       puts("");
     37     }
     38   
     39   return 0;
     40 
     41 }