fork download
  1. #include <bits/stdc++.h>
  2. #include <chrono>
  3. using namespace std;
  4. using namespace chrono;
  5.  
  6. // #include <ext/pb_ds/assoc_container.hpp>
  7. // #include <ext/pb_ds/tree_policy.hpp>
  8. // using namespace __gnu_pbds;
  9. // template<class T> using oset =tree<T, null_type, less_equal<T>, rb_tree_tag,tree_order_statistics_node_update>;
  10.  
  11. // Aliases to op
  12. using ll = long long;
  13. using ull = unsigned long long;
  14. using ld = double;
  15.  
  16.  
  17. // Constants
  18. constexpr ll INF = 4e18;
  19. constexpr ld EPS = 1e-9;
  20. constexpr ll MOD = 998244353;
  21.  
  22. // Macros
  23. #define F first
  24. #define S second
  25. #define all(x) begin(x), end(x)
  26. #define allr(x) rbegin(x), rend(x)
  27. typedef vector<int> vi;
  28. typedef pair<int,int> pi;
  29. // #define insert push_back
  30. #define pb push_back
  31. #define MP make_pair
  32. #define endl '\n'
  33. #define rep(i,a,b) for (int i = a; i < b; i++)
  34.  
  35. const ll mod = 998244353;
  36.  
  37. ll inv(ll i) {if (i == 1) return 1; return (mod - ((mod / i) * inv(mod % i)) % mod) % mod;}
  38.  
  39. ll mod_mul(ll a, ll b) {a = a % mod; b = b % mod; return (((a * b) % mod) + mod) % mod;}
  40.  
  41. ll mod_add(ll a, ll b) {a = a % mod; b = b % mod; return (((a + b) % mod) + mod) % mod;}
  42.  
  43. ll mod_sub(ll a, ll b) {a = a % mod; b = b % mod; return (((a - b + mod) % mod) + mod) % mod;}
  44.  
  45. ll ceil_div(ll a, ll b) {return a % b == 0 ? a / b : a / b + 1;}
  46.  
  47. ll pwr(ll a, ll b) {a %= mod; ll res = 1; while (b > 0) {if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1;} return res;}
  48.  
  49. vector<ll> sieve(int n) {int*arr = new int[n + 1](); vector<ll> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
  50. template <typename T> // cin >> vector<T>
  51. istream &operator>>(istream &istream, vector<T> &v)
  52. {
  53. for (auto &it : v)
  54. cin >> it;
  55. return istream;
  56. }
  57. template <typename T> // cout << vector<T>
  58. ostream &operator<<(ostream &ostream, const vector<T> &c)
  59. {
  60. for (auto &it : c)
  61. cout << it << " ";
  62. return ostream;
  63. }
  64.  
  65. // Mathematical functions
  66. int GCD(int a, int b)
  67. {
  68. while (b)
  69. {
  70. a %= b;
  71. swap(a, b);
  72. }
  73. return a;
  74. }
  75.  
  76. int GCD_extended(int a, int b, int &x, int &y)
  77. {
  78. x = 1, y = 0;
  79. int x1 = 0, y1 = 1, a1 = a, b1 = b;
  80. while (b1)
  81. {
  82. int q = a1 / b1;
  83. tie(x, x1) = make_tuple(x1, x - q * x1);
  84. tie(y, y1) = make_tuple(y1, y - q * y1);
  85. tie(a1, b1) = make_tuple(b1, a1 - q * b1);
  86. }
  87. return a1;
  88. }
  89. int LCM(int a, int b)
  90. {
  91. return ((ll)a * b) / GCD(a, b);
  92. }
  93.  
  94. ll modpow(ll x, ll n, int m = MOD)
  95. {
  96. if (x == 0 && n == 0)
  97. return 0; // undefined case
  98. ll res = 1;
  99. while (n > 0)
  100. {
  101. if (n % 2)
  102. res = (res * x) % m;
  103. x = (x * x) % m;
  104. n /= 2;
  105. }
  106. return res;
  107. }
  108.  
  109. int modinv(int x, int m = MOD)
  110. {
  111. return modpow(x, m - 2, m);
  112. }
  113.  
  114. mt19937 rng;
  115. int getRandomNumber(int l, int r)
  116. {
  117. uniform_int_distribution<int> dist(l, r);
  118. return dist(rng);
  119. }
  120.  
  121.  
  122.  
  123.  
  124. ll binToDec(string s) { return bitset<64>(s).to_ullong(); }
  125. string decToBin(ll a) { return bitset<64>(a).to_string(); }
  126.  
  127. ll andOperator(ll a, ll b)
  128. {
  129. ll shiftcount = 0;
  130.  
  131. while (a != b and a > 0)
  132. {
  133. shiftcount++;
  134. a = a >> 1;
  135. b = b >> 1;
  136. }
  137. return int64_t(a << shiftcount);
  138. }
  139. ll factorial(ll n){
  140. if (n==0){
  141. return 1;
  142. }
  143. ll ans=1;
  144. for (ll i=1;i<=n;i++){
  145. ans=mod_mul(ans,i);
  146. }
  147. return ans;
  148. }
  149.  
  150.  
  151.  
  152. ll lcm(ll a,ll b){
  153. ll g=__gcd(a,b);
  154. return (a*b/g);
  155. }
  156.  
  157.  
  158. long long int power(int base, int exp)
  159. {
  160. if (exp == 0)
  161. return 1;
  162. else if (exp == 1)
  163. return base;
  164. else
  165. {
  166. long long int calc;
  167. if (exp % 2 == 0)
  168. {
  169. calc = power(base, exp/2);
  170. calc *= calc;
  171. }
  172. else
  173. {
  174. calc = base*power(base, exp-1);
  175. }
  176. return calc;
  177. }
  178. }
  179. class Compare {
  180. public:
  181. bool operator()(pair<int,int> a, pair<int,int> b)
  182. {
  183. int diff=a.second-a.first;
  184. int diff2=b.second-b.first;
  185.  
  186. if (diff == diff2) {
  187. return a.first>b.first;
  188. }
  189.  
  190.  
  191.  
  192. return diff<diff2;
  193. }
  194. };
  195.  
  196. bool get(ll a,ll b, ll x){
  197. if (a<b){
  198. swap(a,b);
  199. }
  200. if (x==a || x==b){
  201. return true;
  202. }
  203. if (a==0 || b==0){
  204. return false;
  205. }
  206. return get(a%b,b,x);
  207. }
  208.  
  209.  
  210. long long binpow(long long a, long long b, long long m) {
  211. a %= m;
  212. long long res = 1;
  213. while (b > 0) {
  214. if (b & 1)
  215. res = res * a % m;
  216. a = a * a % m;
  217. b >>= 1;
  218. }
  219. return res;
  220. }
  221.  
  222.  
  223.  
  224. ll nCr(ll n, ll r,vector<ll>&f) {
  225. if (n<r){
  226. return 0;
  227. }
  228. ll ans=f[n];
  229. // ans=mod_mul(ans,inv(f[r]));
  230. ans=mod_mul(ans,inv(f[n-r]));
  231. return ans;
  232. }
  233.  
  234.  
  235. ll mysqrt(ll n){
  236. ll ans=0;
  237. ll low=1;
  238. ll high=1e9;
  239. while(low<=high){
  240. ll md=(low+high)/2;
  241. if (md*md<=n){
  242. ans=md;
  243. low=md+1;
  244. }
  245. else{
  246. high=md-1;
  247. }
  248. }
  249. return ans;
  250. }
  251.  
  252.  
  253.  
  254. bool cmp(pair<ll, ll>& a,
  255. pair<ll, ll>& b)
  256. {
  257. return a.second < b.second;
  258. }
  259.  
  260.  
  261.  
  262. bool check(ll i,ll n,ll k){
  263. ll x=i;
  264. ll par=x/2+1;
  265. ll st=1+(par-1)*(n/i);
  266. ll en=st+n/i-1;
  267. if (((en+st)/2)==k){
  268. return true;
  269. }
  270. return false;
  271.  
  272. }
  273.  
  274. void solve(){
  275. ll a,b;
  276. ll xk ,yk ,xq, yq;
  277. cin>>a>>b;
  278. cin>>xk>>yk;
  279. cin>>xq>>yq;
  280.  
  281. int count = 0;
  282. int c = a+b;
  283. int l =abs(abs(xq)-abs(xk));
  284. int m =abs(abs(yq)-abs(yk));
  285.  
  286.  
  287. if(l < c || m < c && l+m<c){
  288. count=0;
  289. }else if( l== c && m == c){
  290. if(l/2 == a && l/2 ==b){
  291. count =1;
  292. }
  293. else count=2;
  294. }else if(l==0 && m/2 == c){
  295. if(m%2 == 1){
  296. count =0;
  297. }
  298. else count =2;
  299. }else if(m==0 && l/2 == c){
  300. if(l%2 == 1){
  301. count=0;
  302. }
  303. else count=2;
  304. }
  305. else count = 2;
  306. cout << count <<endl;
  307.  
  308. // a+b in horizontail then a+b vertical
  309. // b+a in horizontal then b+a in vertical
  310.  
  311. //if there is queen ans++;
  312.  
  313.  
  314. }
  315.  
  316.  
  317.  
  318. int main(){
  319. ios::sync_with_stdio(0);
  320. cin.tie(0);
  321. cout.tie(0);
  322. int T;
  323. cin>>T;
  324. auto start1 = high_resolution_clock::now();
  325. while(T--){
  326. solve();
  327. }
  328. // auto stop1 = high_resolution_clock::now();
  329. // auto duration = duration_cast<microseconds>(stop1 - start1);
  330. // cerr << "Time: " << duration . count() / 1000 << " ms" << endl;
  331.  
  332. return 0;
  333. }
Success #stdin #stdout 0.01s 5284KB
stdin
4
2 1
0 0
3 3
1 1
3 1
1 3
4 4
0 0
8 0
4 2
1 4
3 4
stdout
2
1
2
0