Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<unordered_map>
- #define long long long
- #define nln '\n'
- using namespace std;
- int main()
- {
- cin.tie(0)->sync_with_stdio(0);
- cout.tie(0)->sync_with_stdio(0);
- //freopen("vacham.inp", "r", stdin);
- while (1)
- {
- long n; cin >> n;
- if (n == 0) break;
- long g; cin >> g;
- unordered_map<long, bool> prw, pcl, pd1, pd2;
- long res = 0;
- while (g--)
- {
- long k, x, y, s, t;
- cin >> k >> x >> y >> s >> t;
- for (long i = 0; i < k; ++i)
- {
- long xx = x+i*s, yy = y+i*t;
- if (!prw[xx]) prw[xx] = 1; else ++res;
- if (!pcl[yy]) pcl[yy] = 1; else ++res;
- if (!pd1[xx+yy]) pd1[xx+yy] = 1; else ++res;
- if (!pd2[xx-yy]) pd2[xx-yy] = 1; else ++res;
- }
- }
- cout << res << nln;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment