Advertisement
Guest User

Untitled

a guest
Oct 16th, 2011
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <assert.h>
  4. #include <sstream>
  5. #include <complex>
  6. #include <numeric>
  7. #include <cstring>
  8. #include <vector>
  9. #include <string>
  10. #include <cstdio>
  11. #include <queue>
  12. #include <cmath>
  13. #include <map>
  14. #include <set>
  15.  
  16. using namespace std;
  17.  
  18. #define all(a)          (a).begin(), (a).end()
  19. #define sz(a)           int((a).size())
  20. #define FOR(i, a, b)    for (int i(a); i < b; ++i)
  21. #define REP(i, n)       FOR(i, 0, n)
  22. #define UN(v)           sort(all(v)), (v).erase(unique((v).begin(), (v).end()), (v).end())
  23. #define CL(a, b)        memset(a, b, sizeof a)
  24. #define pb              push_back
  25. #define X               first
  26. #define Y               second
  27.  
  28. typedef long long ll;
  29. typedef vector <int> vi;
  30. typedef pair <int, int> pii;
  31.  
  32. pii operator + (const pii &p, const pii &q) {
  33.     return pii(p.X + q.X, p.Y + q.Y);
  34. }
  35.  
  36. int main() {
  37.     #ifndef LocalHost
  38.     freopen("circles.in", "r", stdin);
  39.     freopen("circles.out", "w", stdout);
  40.     #endif
  41.     for (int n, R; cin >> n >> R && (n || R); ) {
  42.         vector<pii> p(n), q, v;
  43.         REP (i, n) {
  44.             cin >> p[i].X >> p[i].Y;
  45.         }
  46.         q = p;
  47.         sort(all(q));
  48.         for (int S = sqrt(R), x = -S; x <= S; ++x) {
  49.             int y = sqrt(R - x * x);
  50.             if (x * x + y * y == R) {
  51.                 v.pb(pii(x, -y));
  52.                 if (y) v.pb(pii(x, y));
  53.             }
  54.         }
  55.         vi res(n);
  56.         REP (l, sz(v)) {
  57.             for (int i = 0, j = 0; i < n; ++i) {
  58.                 for (; j < n && q[j] + v[l] < q[i]; ++j);
  59.                 if (j < n && q[j] + v[l] == q[i]) {
  60.                     ++res[i];
  61.                 }
  62.             }
  63.         }
  64.         REP (i, n) {
  65.             if (i) cout << ' ';
  66.             cout << res[lower_bound(all(q), p[i]) - q.begin()];
  67.         }
  68.         cout << endl;
  69.     }
  70.     return 0;
  71. }
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement