jakaria_hossain

lightoj - 1202 - Bishops

Aug 22nd, 2019
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. int color(ll a, ll b)
  5. {
  6. if(a%2==1)
  7. {
  8. if(b%2==1)return 1;
  9. else return 2;
  10. }
  11. else
  12. {
  13. if(b%2==1)return 2;
  14. else return 1;
  15. }
  16. }
  17. int main()
  18. {
  19. int t;
  20. cin>>t;
  21. for(int i=1;i<=t;i++)
  22. {
  23. ll a,b,c,d;
  24. bool f=true;
  25. cin>>a>>b>>c>>d;
  26. if(color(a,b)==color(c,d))
  27. {
  28. if(abs(a-c)==abs(b-d))printf("Case %d: 1\n",i);
  29. else printf("Case %d: 2\n",i);
  30. }
  31. else printf("Case %d: impossible\n",i);
  32. }
  33. }
RAW Paste Data