Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <algorithm>
- #include <math.h>
- #include<string>
- #include<vector>
- #define pi acos(-1.0)
- #define ll long long int
- #define sc scanf
- #define pf printf
- #define fin for(ll i=0; i<n; i++)
- #define fjm for(ll j=0; j<m; j++)
- #define fr(i,a,n) for(ll i=a; i<n; i++)
- #define rf(i,n,a) for(ll i=n-1; i>=a; i--)
- #define readfirst() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
- using namespace std;
- ll gcd(ll p, ll q) {
- return q==0?p:gcd(q,p%q);
- }
- int main() {
- readfirst();
- ll t, x1, x2, x3, y1, y2, y3;
- cin >> t;
- while(t--) {
- cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
- ll x, y, a, b, c, d, s=0;
- s=abs(x1-x2)+abs(y1-y2);
- if(x1==x3 && x2==x3) {
- a=min(y1,y2);
- b=max(y1,y2);
- if(y3>a && y3<b) s+=2;
- }
- else if(y1==y3 && y2==y3) {
- c=min(x1,x2);
- d=max(x1,x2);
- if(x3>c && x3<d) s+=2;
- }
- cout << s << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement