Untitled

mail@pastecode.io avatar
unknown
plain_text
14 days ago
659 B
2
Indexable
Never
#include <bits/stdc++.h>

using namespace std;

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