daily pastebin goal
60%
SHARE
TWEET

J - SEERC 2014

a guest Jan 22nd, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. struct Triangle {
  6.   int add_l, add_c;
  7.   int sub_l, sub_c;
  8.   int o;
  9.   Triangle () {}
  10.   Triangle (int _add_l, int _add_c, int _sub_l, int _sub_c, int _o) :
  11.     add_l (_add_l), add_c (_add_c), sub_l (_sub_l), sub_c (_sub_c), o (_o) {}
  12. };
  13.  
  14. const int NMAX = 3e4 + 5;
  15.  
  16. Triangle a[NMAX];
  17. int curr[NMAX];
  18.  
  19. int n, m, ans;
  20.  
  21. void press (int pos) {
  22.   curr[pos] ^= 1;
  23.   if (curr[pos]) ++ans;
  24.   else --ans;
  25. }
  26.  
  27. int main() {
  28.   freopen ("j.in", "r", stdin);
  29.   scanf ("%d\n%d\n", &n, &m);
  30.   for (int i = 1; i <= m; ++i) {
  31.     int l, c, p, o;
  32.     scanf ("%d %d %d %d\n", &l, &c, &p, &o);
  33.     l += n, c += n;
  34.     if (o == 0) {
  35.       a[i] = {l, c - p + 1, l + p, c, o};
  36.     } else if (o == 1) {
  37.       a[i] = {l, c, l + p, c + p - 1, o};
  38.     } else if (o == 2) {
  39.       a[i] = {l - p + 1, c, l + 1, c, o};
  40.     } else if (o == 3) {
  41.       a[i] = {l - p + 1, c, l + 1, c, o};
  42.     }
  43.   }
  44.  
  45.   for (int row = 1; row <= 3 * n; ++row) {
  46.     for (int i = 1; i <= m; ++i) {
  47.       if (row < a[i].add_l || row > a[i].sub_l) {
  48.         continue;
  49.       }
  50.       if (row == a[i].add_l || row == a[i].sub_l) {
  51.         for (int col = a[i].add_c; col <= a[i].sub_c; ++col) {
  52.           press (col);
  53.         }
  54.       }
  55.       int o = a[i].o;
  56.       if (o == 0) {
  57.         press (a[i].add_c);
  58.         ++a[i].add_c;
  59.       } else if (o == 1) {
  60.         press (a[i].sub_c);
  61.         --a[i].sub_c;
  62.       } else if (o == 2) {
  63.         press (a[i].add_c);
  64.         ++a[i].add_c;
  65.       } else {
  66.         press (a[i].add_c);
  67.         --a[i].add_c;
  68.       }
  69.     }
  70.   }
  71.  
  72.   printf ("%d\n", ans);
  73.  
  74.   fclose (stdin);
  75.   return 0;
  76. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top