题:https://codeforces.com/contest/1080/problem/C

题意:给n*m的二维坐标系,每个位置(xi,yi)都表示一个方格,(1,1)的位置是白色,整个坐标系黑白相间分布。有俩个操作,第一个操作是选定一个矩阵用白色给覆盖,第二个操作选定一个矩阵用黑色覆盖,问最后的白色块和黑色块各是多少?

分析:我们先分别独立地求这俩次操作,然后因为黑色覆盖在后,所以我们就把俩次操作可能相交的部分进行减去相应的贡献即可,也就是对面积交进行处理。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll area(ll x1,ll y1,ll x2,ll y2){
ll a=x2-x1+,b=y2-y1+;
ll ans=a*b/;
if(a*b%!=&&((x1+y1)%==))
ans++;
return ans;
}
ll cross(ll x1,ll y1,ll x2,ll y2,ll x3,ll y3,ll x4,ll y4){
ll lx=max(x1,x3);
ll ly=max(y1,y3);
ll rx=min(x2,x4);
ll ry=min(y2,y4);
if(lx>rx||ly>ry)
return ; ll a=rx-lx+,b=ry-ly+;
ll ans=a*b/;
if(a*b%!=&&((lx+ly)%==))
ans++;
return a*b-ans;
} int main()
{
int t;
cin>>t;
while(t--){
ll n,m;
cin>>n>>m;
ll x1,y1,x2,y2,x3,y3,x4,y4;
cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
///单独对第一次操作进行统计
ll sw=n*m/;//w
if((n*m)&)
sw++;
sw+=(x2-x1+)*(y2-y1+)-area(x1,y1,x2,y2);///加上覆盖白后增加的S
///单独对第二次操作进行统计
ll fullblack=area(x3,y3,x4,y4);
///面积交的部分
ll Sjiao=cross(x1,y1,x2,y2,x3,y3,x4,y4);
///处理答案
ll ans=sw-fullblack-Sjiao;
cout<<ans<<" "<<n*m-ans<<endl;
}
return ;
}

Codeforces Round #524 (Div. 2)C 二维坐标系求俩矩形面积交的更多相关文章

  1. Codeforces Round #524 (Div. 2) C. Masha and two friends(矩形相交)

    C. Masha and two friends time limit per test 1 second memory limit per test 256 megabytes input stan ...

  2. Codeforces Round #524 (Div. 2)(前三题题解)

    这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...

  3. Codeforces Round #524 (Div. 2) codeforces 1080A~1080F

    目录 codeforces1080A codeforces 1080B codeforces 1080C codeforces 1080D codeforces 1080E codeforces 10 ...

  4. Codeforces Round #524 (Div. 2) F. Katya and Segments Sets(主席树)

    https://codeforces.com/contest/1080/problem/F 题意 有k个区间,区间的种类有n种,有m个询问(n,m<=1e5,k<=3e5),每次询问a,b ...

  5. Codeforces Round #524 (Div. 2) E. Sonya and Matrix Beauty(字符串哈希,马拉车)

    https://codeforces.com/contest/1080/problem/E 题意 有一个n*m(<=250)的字符矩阵,对于每个子矩阵的每一行可以任意交换字符的顺序,使得每一行每 ...

  6. Codeforces Round #524 (Div. 2) B. Margarite and the best present

    B. Margarite and the best present 题目链接:https://codeforces.com/contest/1080/problem/B 题意: 给出一个数列:an=( ...

  7. Codeforces Round #524 (Div. 2) D. Olya and magical square

    D. Olya and magical square 题目链接:https://codeforces.com/contest/1080/problem/D 题意: 给出一个边长为2n的正方形,每次可以 ...

  8. Codeforces Round #524 (Div. 2) F

    题解: 首先这个东西因为强制在线区间查询 所以外面得套线段树了 然后考虑几条线段怎么判定 我们只需要按照右端点排序,然后查询的时候查找最右节点的前缀最大值就可以了 然后怎么合并子区间信息呢 (刚开始我 ...

  9. Codeforces Round #524 (Div. 2)

    A. Petya and Origamitime limit per test1 secondmemory limit per test256 megabytesinputstandard input ...

随机推荐

  1. Vue 获取时间戳返回自定义时间格式

    直接在Vue全局函数定义: Vue.prototype.padLeftZero = function(str) { return ('00' + str).substr(str.length); }; ...

  2. LabVIEW面向对象的ActorFramework(3)

    四.LabVIEW面向对象的编程架构:Actor Framework Actor Framework是一个软件类库,用以支持编写有多个VI独立运行且相互间可通信的应用程序,在该类型应用程序中,每个VI ...

  3. No enclosing instance of type test is accessible. Must qualify the allocation with an enclosing inst

    今日遇到一个报错如下: No enclosing instance of type test is accessible. Must qualify the allocation with an en ...

  4. Innodb特性以及实现原理

    Innodb五大特性 1.insert buffer2.double write3.自适应哈希索引4.异步io5.邻接页刷新 1.insert buffer(change buffer) 作用:将非聚 ...

  5. js动态删除行错误

    Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. js ...

  6. Sequence Models Week 1 Character level language model - Dinosaurus land

    Character level language model - Dinosaurus land Welcome to Dinosaurus Island! 65 million years ago, ...

  7. VS2013 MFC opencv 播放视频

    看网上有很多人用的还是CvvImage类,但是Opencv3.0已经没有CvvImage这个类了.百度得之可以使用以前的类,稍作修改就可以了. 头文件: #pragma once #ifndef CV ...

  8. CTF密码学常见加密解密总结

    https://blog.csdn.net/qq_40837276/article/details/83080460

  9. HDU 1588 矩阵快速幂 嵌套矩阵

    这个题目搞了我差不多一个下午,之前自己推出一个公式,即 f[n+k]=k*f[n]+f[n-1]结果发现根本不能用,无法降低复杂度. 后来又个博客的做法相当叼,就按他的做法来了 即 最终求得是 S(n ...

  10. 寒假day12

    今天写了一点论文,刷了一些算法题