fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. int X1, Y1, X2, Y2;
  7. cin >> X1 >> Y1 >> X2 >> Y2;
  8. if(X1 - 1 == X2 and Y1 + 1 == Y2 || X1 == X2 and Y1 + 1 == Y2 || X1+1 == X2 and Y1 == Y2 || (abs(X1-X2 == 1)) and
  9. (abs(Y1-Y2 == 1)) || X1 == X2 and (abs(Y1-Y2 ==1)) || X1 + 1 == X2 and Y1 - 1 == Y2 || X1 + 1 and Y1 == Y2
  10. || X1 + 1 == X2 and Y1 + 1 == Y2){
  11. cout << "YES";
  12. }else if(X1 != X2){
  13. cout << "NO";
  14. }
  15. return 0;
  16. }
Success #stdin #stdout 0s 5324KB
stdin
3 3 
5 3
stdout
YES