-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1547A.cpp
More file actions
37 lines (32 loc) · 1.06 KB
/
1547A.cpp
File metadata and controls
37 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fo(i,n) for(int i = 0; i < n; i++)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
void solve(){
pair<int,int>a,f,b;
cin >> a.first>>a.second;
cin >>b.first>>b.second;
cin >>f.first>>f.second;
if(a.first==b.first ){
if(f.first==a.first){
if(f.second<min(a.second,b.second)||f.second>max(a.second,b.second))cout<<abs(a.second-b.second)<<endl;
else cout<<abs(a.second-b.second)+2<<endl;
}else cout<<abs(a.second-b.second)<<endl;
}else if(a.second==b.second){
if(f.second==a.second){
if(f.first<min(a.first,b.first)||f.first>max(a.first,b.first))cout<<abs(a.first-b.first)<<endl;
else cout<<abs(a.first-b.first)+2<<endl;
}else cout<<abs(a.first-b.first)<<endl;
}else{
cout<<abs(a.second-b.second)+abs(a.first-b.first)<<endl;
}
}
int main() {_
int t;cin >> t;
while(t--)solve();
return 0;
}