If the absolute difference between the row of the current cell and the target cell is equal to the absolute difference between the column of the current cell and the target cell, then the target cell is reachable from current cell in one move, otherwise not.

C++ code:

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t; cin >> t;

    while(t--)
    {
        int x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;

        if(abs(x1-x2) == abs(y1-y2)) cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}

Statistics

92% Solution Ratio
Mr.adnanEarliest, Oct '16
rayhan50001Fastest, 0.0s
Raiyan13Lightest, 0 B
bokaifShortest, 94B
Toph uses cookies. By continuing you agree to our Cookie Policy.