Iamtui1010

vacham.cpp

Jan 5th, 2022
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include<iostream>
  2. #include<unordered_map>
  3.  
  4. #define long long long
  5. #define nln '\n'
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     cin.tie(0)->sync_with_stdio(0);
  12.     cout.tie(0)->sync_with_stdio(0);
  13.     //freopen("vacham.inp", "r", stdin);
  14.     while (1)
  15.     {
  16.         long n; cin >> n;
  17.         if (n == 0) break;
  18.         long g; cin >> g;
  19.         unordered_map<long, bool> prw, pcl, pd1, pd2;
  20.         long res = 0;
  21.         while (g--)
  22.         {
  23.             long k, x, y, s, t;
  24.             cin >> k >> x >> y >> s >> t;
  25.             for (long i = 0; i < k; ++i)
  26.             {
  27.                 long xx = x+i*s, yy = y+i*t;
  28.                 if (!prw[xx]) prw[xx] = 1; else ++res;
  29.                 if (!pcl[yy]) pcl[yy] = 1; else ++res;
  30.                 if (!pd1[xx+yy]) pd1[xx+yy] = 1; else ++res;
  31.                 if (!pd2[xx-yy]) pd2[xx-yy] = 1; else ++res;
  32.             }
  33.         }
  34.         cout << res << nln;
  35.     }
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment