fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <map>
  5. #include <deque>
  6. #include <cmath>
  7. #include <set>
  8. #include <unordered_map>
  9.  
  10. using namespace std;
  11.  
  12. #define all(v) ((v).begin()), ((v).end())
  13. #define sz(v) ((int)((v).size()))
  14. #define clr(v, d) memset(v, d, sizeof(v))
  15. #define rep(i, v) for (int i = 0; i < sz(v); ++i)
  16. #define lp(i, n) for (int i = 0; i < (int)(n); ++i)
  17. #define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
  18. #define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
  19. typedef long long ll;
  20.  
  21. void fast_io()
  22. {
  23. ios_base::sync_with_stdio(false);
  24. cin.tie(nullptr);
  25. cout.tie(nullptr);
  26. #ifndef ONLINE_JUDGE
  27. freopen("input.txt", "r", stdin);
  28. freopen("output.txt", "w", stdout);
  29. #endif
  30. }
  31. int main()
  32. {
  33. fast_io();
  34.  
  35. double x01=0,y01=0,x02=0,y02=0;
  36. cin >> x01 >> y01 >> x02 >> y02;
  37.  
  38. double x11=0,y11=0,x12=0,y12=0;
  39. cin >> x11 >> y11 >> x12 >> y12;
  40.  
  41. double radius0 = sqrt((x01-x02)*(x01-x02) + (y01-y02)*(y01-y02))/2;
  42. double radius1 = sqrt((x11-x12)*(x11-x12) + (y11-y12)*(y11-y12))/2;
  43.  
  44. double center0x = (x01+x02)/2;
  45. double center0y = (y01+y02)/2;
  46. double center1x = (x11+x12)/2;
  47. double center1y = (y11+y12)/2;
  48.  
  49. double centers = sqrt((center1x-center0x)*(center1x-center0x) + (center1y-center0y)*(center1y-center0y));
  50.  
  51. if (centers < radius0+radius1){
  52. if (x01 >= x11 && y01 >= y11 || x01 >= x11 && y01 == y11 || y01 >= y11 && x01 == x11){
  53. cout << x01 << ' ' << y01 << ' ';
  54. }else{
  55. cout << x11 << ' ' << y11 << ' ';
  56. }
  57. if (x02 <= x12 && y02 <= y12 || x02 <= x12 && y02 == y12 || y02 <= y12 && x02 == x12){
  58. cout << x02 << ' ' << y02 << endl;
  59. }else{
  60. cout << x12 << ' ' << y12 << endl;
  61. }
  62. }
  63. else
  64. cout << -1 << endl;
  65. }
Success #stdin #stdout 0.01s 5292KB
stdin
0 0 2 2
1 1 3 3
stdout
1 1 2 2