题: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. soap调用Jar包冲突,SOAPMessageContext

    ================================ ©Copyright 蕃薯耀 2020-01-07 https://www.cnblogs.com/fanshuyao/ soap调用 ...

  2. leetcode - 两数之和Ⅳ 输入BST(653)

    题目描述:给定一个二叉搜索树和一个目标结果,如果 BST 中存在两个元素且它们的和等于给定的目标结果,则返回 true. 解题思路:根据二叉搜索树的特点,对二叉搜索树进行中序遍历可以得到一个从小到达排 ...

  3. spring boot rest 接口集成 spring security(2) - JWT配置

    Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...

  4. no.9亿级用户下的新浪微博平台架构读后感

    微博平台的第三代技术体系,使用正交分解法建立模型:在水平方向,采用典型的三级分层模型,即接口层.服务层与资源层:在垂直方向,进一步细分为业务架构.技术架构.监控平台与服务治理平台. 水平分层 (1)接 ...

  5. python中的单元测试模块unittest

    unittest的属性: 该文以思维导图的形式描述unittest的重要属性. 其中前四个是unittest最核心的三个属性. testcase:测试用例: testsuite:测试套件,多个测试用例 ...

  6. 小程序使用wxs 解决wxml保留2位小数问题

    1.出现溢出表现 从图中可以看到数字超出了很长长度.代码里面是如下这样的.为什么在0.35出现?或者一些相成的计算出现? 而 0.34却不会. 0.41 也会出现,好像是二进制运算出现结果. data ...

  7. java-简单工程模板

    1.maven <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all< ...

  8. Java数据的存储

    在JAVA中,有六个不同的地方可以存储数据: 1. 寄存器(register).这是最快的存储区,因为它位于不同于其他存储区的地方——处理器内部.但是寄存器的数量极其有限,所以寄存器由编译器根据需求进 ...

  9. linux.linuxidc.com - /2011年资料/Android入门教程/

    本文转自 http://itindex.net/detail/15843-linux.linuxidc.com-%E8%B5%84%E6%96%99-android Shared by Yuan 用户 ...

  10. 导入的Java Web项目提示找不到javax.servlet.http.*包

    在网上下载了个Java web项目,导入到eclipse发现以下错误 解决办法: 1.右击项目,进入Configure Build Path 2.在Libraries标签下点击Add Library. ...