Advertisement
Guest User

Problem L

a guest
Nov 26th, 2017
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. #include <algorithm>
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. int max(int a, int b, int c, int d) { return max(max(a, b), max(c, d)); }
  7.  
  8. const int MAXN = 200000;
  9. const int MAXM = 3000;
  10. const int M = MAXM + 10;
  11. short a[M][M];
  12. short b[M][M];
  13.  
  14. int main() {
  15.   int n;
  16.   scanf("%d", &n);
  17.   for (int i = 0; i < n; ++i) {
  18.     char type;
  19.     int x, y, len;
  20.     scanf(" %c%d%d%d", &type, &x, &y, &len);
  21.     if (type == 'A') {
  22.       const int x0 = M / 2 + x - len / 2;
  23.       const int y0 = M / 2 + y - len / 2;
  24.       a[x0][y0] = max((int)a[x0][y0], len);
  25.     } else {
  26.       const int x0 = M / 2 + x - len / 2;
  27.       const int y0 = M / 2 + y;
  28.       b[x0][y0] = max((int)b[x0][y0], len);
  29.     }
  30.   }
  31.  
  32.   double ret = 0.0;
  33.   for (int x = 1; x < M - 1; ++x) {
  34.     for (int y = 1; y < M - 1; ++y) {
  35.       a[x][y] = max(a[x][y],
  36.                     a[x - 1][y] - 1, a[x - 1][y - 1] - 1, a[x][y - 1] - 1);
  37.       b[x][y] = max(b[x][y],
  38.                     b[x - 1][y] - 1, b[x - 1][y - 1] - 2, b[x - 1][y + 1] - 2);
  39.       if (a[x][y - 1] >= 1) {
  40.         ret += 1.0;
  41.       } else {
  42.         if (b[x][y - 1] >= 1) ret += 0.25;
  43.         if (b[x][y] >= 1) ret += 0.25;
  44.         if (b[x][y - 1] >= 2 || b[x][y] >= 2) ret += 0.25;
  45.         if (b[x - 1][y - 1] >= 2 || b[x - 1][y] >= 2) ret += 0.25;
  46.       }
  47.     }
  48.   }
  49.   printf("%.2lf\n", ret);
  50.   return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement