Advertisement
jw910731

CodeForces ChessBoard

Nov 24th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef struct{long long x,y;}cord;
  4. typedef struct{cord l,u;}rect;
  5. inline long long area(rect r){return max(r.u.x - r.l.x + 1, 1LL) * max(r.u.y - r.l.y + 1, 1LL);}
  6. inline long long calcW(rect r){
  7.     if(area(r) % 2 != 0 && r.l.x % 2 == 1)
  8.         return area(r)/2 + 1;
  9.     return area(r)/2;
  10. }
  11. inline long long calcB(rect r){return area(r) - calcW(r);}
  12. inline bool inRect(rect r, cord c){
  13.     return (c.x - r.l.x) >= 0 && (c.y - r.l.y) >= 0 && (r.u.x - c.x) >= 0 && (r.u.y - c.y) >= 0;
  14. }
  15. int main(){
  16.     long long t,n,m;
  17.     scanf("%lld",&t);
  18.     while(t--){
  19.         scanf("%lld%lld",&n,&m);
  20.         rect white,black;
  21.         scanf("%lld%lld%lld%lld", &white.l.x, &white.l.y, &white.u.x, &white.u.y);
  22.         scanf("%lld%lld%lld%lld", &black.l.x, &black.l.y, &black.u.x, &black.u.y);
  23.         long long addW=0,addB=0;
  24.         addW = calcB(white);
  25.         addB = calcW(black);
  26.         printf("%d %d\n",inRect(white,black.l),inRect(white,black.u));
  27.     }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement