Advertisement
Tahsin24

Untitled

Oct 31st, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cstring>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <vector>
  7. #include <string>
  8. using namespace std;
  9.  
  10. struct router
  11. {
  12. public:
  13. int rx, ry, r;
  14. //double r1 = (double)r;
  15. int distance_from_center(int a, int b)
  16. {
  17. int dis = ((rx - a)*(rx - a) + (ry - b)*(ry - b));
  18. if (dis <= (r*r))
  19. {
  20. /*cout << "dis = " << dis<< " "<<"r^2 = "<<r * r<< endl;
  21. cout << 1 << endl;*/
  22. return 1;
  23. }
  24. /*cout << "dis = " << dis << " " << "r^2 = " << r * r << endl;
  25. cout << -1 << endl;*/
  26. return-1;
  27. }
  28.  
  29. };
  30.  
  31.  
  32. int main()
  33. {
  34. int t;
  35. cin >> t;
  36. int z = 1;
  37. while (z <= t)
  38. {
  39. int n, y;
  40. cin >> n >> y;
  41. vector<router>v;
  42. for (int i = 0; i < n; i++)
  43. {
  44. int a, b, c;
  45. cin >> a >> b >> c;
  46. router k;
  47. k.rx = a;
  48. k.ry = b;
  49. k.r = c;
  50. v.push_back(k);
  51. }
  52. int d = 0;
  53. cout << "Case " << z << ": " << endl;
  54. for (int i = 0; i < y; i++)
  55. {
  56. d = 0;
  57. int a, b;
  58. cin >> a >> b;
  59. for (int j = 0; j < v.size(); j++)
  60. {
  61. if (v[j].distance_from_center(a, b) == 1)
  62. {
  63. d = 1;
  64. break;
  65. }
  66. }
  67.  
  68. if (d == 1)cout << "Yes" << endl;
  69. else cout << "No" << endl;
  70. }
  71. z++;
  72. v.clear();
  73. }
  74.  
  75.  
  76. return 0;
  77. }
  78.  
  79. /*
  80.  
  81. 3 5 L D L D W 6 L D W L L L 3 D D W
  82.  
  83. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement