Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
655 B
4
Indexable
#include <bits/stdc++.h>

using namespace std;

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