Advertisement
bishalbiswas

F

Oct 31st, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1.  
  2. using namespace std;
  3. //{ C-headers
  4. #include <cstdio>
  5. #include <cstdlib>
  6. #include <cmath>
  7. #include <cstring>
  8. #include <climits>
  9. #include <cfloat>
  10. #include <cctype>
  11. #include <cassert>
  12. #include <ctime>
  13. //}
  14. //{ C++-headers
  15. #include <iostream>
  16. #include <iomanip>
  17. #include <sstream>
  18. #include <algorithm>
  19. #include <utility>
  20. #include <string>
  21. #include <stack>
  22. #include <queue>
  23. #include <vector>
  24. #include <set>
  25. #include <map>
  26. //}
  27. //{ Loops
  28. #define forab(i,a,b) for (__typeof(b) i = (a); i <= (b); ++i)
  29. #define rep(i,n) forab (i, 0, (n) - 1)
  30. #define For(i,n) forab (i, 1, n)
  31. #define rofba(i,a,b) for (__typeof(b) i = (b); i >= (a); --i)
  32. #define per(i,n) rofba (i, 0, (n) - 1)
  33. #define rof(i,n) rofba (i, 1, n)
  34. #define forstl(i,s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
  35. //}
  36. //{ Floating-points
  37. #define EPS 1e-7
  38. #define abs(x) (((x) < 0) ? - (x) : (x))
  39. #define zero(x) (abs (x) < EPS)
  40. #define equal(a,b) (zero ((a) - (b)))
  41. #define PI 2*acos (0.0)
  42. //}
  43. typedef long long int64;
  44. typedef unsigned long long int64u;
  45. #define memo(a,v) memset(a,v,sizeof(a))
  46. #define all(a) a.begin(),a.end()
  47. #define db double
  48. #define pb push_back
  49. #define pii pair<int ,int >
  50. #define NL puts("")
  51. //{
  52. //Intput_Output
  53. #define II ({ int a; scanf("%d",&a); a;})
  54. #define IL ({ int64 a; scanf("%lld",&a); a;})
  55. #define ID ({ db a; scanf("%lf",&a); a;})
  56. #define IC ({ char a; scanf("%c",&a); a;})
  57. #define IS ({ string a; cin >> a; a;})
  58. #define ICA(n) ({ char a[n]; scanf("%s",&a); a;})
  59. #define OC printf("Case %d:",cs);
  60. //}
  61. //}
  62. template <class T, class U> inline T max (T &a, U &b)
  63. {
  64. return a > b ? a : b;
  65. }
  66. template <class T, class U> inline T min (T &a, U &b)
  67. {
  68. return a < b ? a : b;
  69. }
  70. template <class T, class U> inline T swap (T &a, U &b)
  71. {
  72. T tmp = a;
  73. a = b;
  74. b = tmp;
  75. }
  76. //int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
  77. //int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
  78. //int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
  79. //int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
  80. const int64 INF = (1ll)<<50;
  81. const int mx = 1e5 + 7;
  82. const int mod = 1000000007 ;
  83. const db pi = PI;
  84. int EQ(double d) {
  85. if ( fabs(d) < EPS ) return 0;
  86. return d > EPS ? 1 : -1 ;
  87. }
  88. struct router{
  89. int x,y,r;
  90. router(int _x,int _y,int _r){
  91. x = _x;
  92. y = _y;
  93. r = _r;
  94. }
  95. };
  96. vector<router>v;
  97. bool inCover(router a,router b){
  98. int x = a.x - b.x,y = a.y - b.y;
  99. int dis = (x*x) + (y*y);
  100. return dis<=a.r;
  101. }
  102. int main() {
  103. #ifdef Sanim
  104. freopen ("in.txt", "r", stdin);
  105. // freopen ("output.txt", "w", stdout);
  106. #endif
  107. int t = II;
  108. For(cs,t){
  109. v.clear();
  110. int n = II,Y = II;
  111. rep(i,n){
  112. int x = II,y = II,r = II;
  113. v.pb(router(x,y,r*r));
  114. }
  115. OC;
  116. NL;
  117. rep(i,Y){
  118. int x = II,y = II;
  119. bool flag = false;
  120. rep(j,n){
  121. if(inCover(v[j],router(x,y,0))){
  122. flag = true;
  123. break;
  124. }
  125. }
  126. if(flag) cout << "Yes" << endl;
  127. else cout << "No" << endl;
  128. }
  129. }
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement