fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int L1, R1, R2, L2;
  7. cin >> L1>> R1>> L2>> R2;
  8. if (L2 < R1 && R2> L1 && R2>R1&&L1<L2) {
  9. cout << L2 <<" "<< R1;
  10. }
  11. else if (L1 > L2 && R2 < R1 && L2 < R1 && L1 < R2) {
  12. cout << L1 <<" "<< R2;
  13. }
  14. else if (L1 == L2 && R1 == R2) {
  15. cout << L1 << " " << R2;
  16. }
  17. else { cout << -1; }
  18. return 0;
  19. }
  20.  
  21.  
  22.  
  23.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
-1