fork(2) download
  1. // iostream is too mainstream
  2. #include <cstdio>
  3. // bitch please
  4. #include <iostream>
  5. #include <vector>
  6. #include <set>
  7. #include <map>
  8. #include <string>
  9. #include <queue>
  10. #include <stack>
  11. #include <algorithm>
  12. #define dibs reserve
  13. #define OVER9000 1234567890
  14. #define tisic 47
  15. #define soclose 10e-7
  16. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  17. #define chocolate win
  18. #define ff first
  19. #define ss second
  20. #define uint unsigned int
  21. // mylittlepony
  22. using namespace std;
  23.  
  24. struct sur {
  25. long long x,y;};
  26.  
  27. long long vs(sur a, sur b, sur c) {
  28. return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);}
  29.  
  30. bool inT(sur a, sur b, sur c, sur P) {
  31. if(vs(b,c,P)*vs(b,c,a) < 0) return false;
  32. if(vs(a,c,P)*vs(a,c,b) < 0) return false;
  33. if(vs(a,b,P)*vs(a,b,c) < 0) return false;
  34. return true;}
  35.  
  36. long long dist(sur a, sur b) {
  37. return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}
  38.  
  39. int main() {
  40. int T;
  41. cin >> T;
  42. for(int i =0; i < T; i++) {
  43. sur tr[3];
  44. for(int j =0; j < 3; j++) cin >> tr[j].x >> tr[j].y;
  45. sur S; int R;
  46. cin >> S.x >> S.y >> R;
  47. sur a =tr[0], b =tr[1], c =tr[2];
  48. if(inT(tr[0],tr[1],tr[2],S)) {cout << "YES\n"; continue;}
  49. if(vs(S,a,b)*vs(S,a,b) <= R*R*dist(a,b)) {
  50. if(dist(a,b)+dist(a,S) >= dist(b,S) && dist(a,b)+dist(b,S) >= dist(a,S))
  51. {cout << "YES\n"; continue;}
  52. else if(min(dist(a,S),dist(b,S)) <= R*R) {cout << "YES\n"; continue;}}
  53. if(vs(S,c,b)*vs(S,c,b) <= R*R*dist(c,b)) {
  54. if(dist(c,b)+dist(c,S) >= dist(b,S) && dist(c,b)+dist(b,S) >= dist(c,S))
  55. {cout << "YES\n"; continue;}
  56. else if(min(dist(c,S),dist(b,S)) <= R*R) {cout << "YES\n"; continue;}}
  57. if(vs(S,a,c)*vs(S,a,c) <= R*R*dist(a,c)) {
  58. if(dist(a,c)+dist(a,S) >= dist(c,S) && dist(a,c)+dist(c,S) >= dist(a,S))
  59. {cout << "YES\n"; continue;}
  60. else if(min(dist(a,S),dist(c,S)) <= R*R) {cout << "YES\n"; continue;}}
  61. cout << "NO\n";}
  62. return 0;}
  63.  
  64. // look at my code
  65. // my code is amazing
Success #stdin #stdout 0s 3348KB
stdin
1
0 0
1 0
0 1
0 2 1
stdout
YES