Untitled

mail@pastecode.io avatar
unknown
plain_text
22 days ago
680 B
3
Indexable
Never
#include <bits/stdc++.h>

using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        long long n, m;
        cin >> n >> m;
        long long x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        
        int ans;
        
        if ((x1 == 1 || x1 == n) && (y1 == 1 || y1 == m) ||
            (x2 == 1 || x2 == n) && (y2 == 1 || y2 == m)) {
            ans = 2;
        } else if (x1 == 1 || x1 == n || y1 == 1 || y1 == m ||
                 x2 == 1 || x2 == n || y2 == 1 || y2 == m) {
            ans = 3;
        } else {
            ans = 4;
        }
        
        cout << ans << endl;
    }
    return 0;
}
Leave a Comment