G. Snake Rana

题目描述

Old Macdonald wants to build a new hen house for his hens. He buys a new rectangular area of size N by M. The night before he builds the hen house, snake Rana devises an evil plan to plant bombs in K distinct cells in the area to kill the hens and eat them for dinner later.

The morning of, Old Macdonald notices that each of the K cells, where snake Rana planted a bomb, have a marking on them. That won’t stop him though, all he must do is build the hen house in an area with no bombs.

Assume that rows are numbered from top to bottom, and columns are numbered from left to right. Old Macdonald now wants to know the number of ways he can choose sub-rectangles of top left coordinates (x1, y1) and bottom right coordinates (x2, y2) (x1 ≤ x2) (y1 ≤ y2) such that there are no bombs in the sub rectangle.

输入

The first line of input is T – the number of test cases.

The first line of each test case is three integers N, M, and K (1 ≤ N, M ≤ 104) (1 ≤ K ≤ 20).

The next K lines each contains distinct pair of integers x, y (1 ≤ x ≤ N) (1 ≤ y ≤ M) - where (x, y) is the coordinate of the bomb.

输出

For each test case, output a line containing a single integer - the number of sub-rectangles that don’t contain any bombs.

样例

inputCopy
3
2 2 1
2 2
6 6 2
5 2
2 5
10000 10000 1
1 1
outputCopy
5
257
2500499925000000

题意

容斥定理 不过因为数据比较大用二进制压缩一下

AC代码

GYM 101350 G. Snake Rana ( 容斥相关推荐

  1. 2017 ACM Arabella Collegiate Programming Contest G. Snake Rana GYM101350G

    先算一下总的子矩阵个数 总共最多只有20个点 状压一下然后枚举 容斥一下 把求出来的答案减去包含1个点的子矩阵再加上包含2个点的减去3个点的-- #include <iostream> # ...

  2. G. Snake Rana 容斥原理

    题意: 统计网格矩形的子矩形数目,其中要求每个格子不能包含一些特殊格子(特殊格子小于20) 思路:统计格子是个老问题,sum=n*(n+1)/2*m*(m+1)/2 这里要求一些格子不合法,显然用总答 ...

  3. 【容斥】2017 ACM Arabella Collegiate Programming Contest

    比赛连接 G. Snake Rana Old Macdonald wants to build a new hen house for his hens. He buys a new rectangu ...

  4. Snake Rana (容斥定理)

    Snake Rana     Gym - 101350G https://cn.vjudge.net/contest/303719#problem/B 题目大意:给定一个矩阵,和矩阵中的一些点,求矩阵 ...

  5. Snake Rana Gym - 101350G

    题目: Old Macdonald wants to build a new hen house for his hens. He buys a new rectangular area of siz ...

  6. Educational Codeforces Round 37 G. List Of Integers (二分,容斥定律,数论)

    G. List Of Integers time limit per test 5 seconds memory limit per test 256 megabytes input standard ...

  7. 【牛客 - 696C】小w的禁忌与小G的长诗(dp 或 推公式容斥)

    题干: 链接:https://ac.nowcoder.com/acm/contest/696/C 来源:牛客网 自从上次小w被奶牛踹了之后,就一直对此耿耿于怀. 于是"cow"成为 ...

  8. 容斥 + 树形dp ---- 2021 icpc 沈阳 L Perfect Matchings

    题目链接 题目大意: 就是给你一个2n2n2n个点的完全图,从这个图里面抽出2n−12n-12n−1条边,这些边形成一颗树,现在问你剩下的图里面点进行完美匹配有多少种方案? 解题思路: 一开始被完美匹 ...

  9. Luogu P4336 [SHOI2016]黑暗前的幻想乡(容斥,矩阵树定理,子集反演)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Luogu P4336 [SHOI2016]黑暗前的幻想乡(容斥,矩阵树定理) Problem n≤1 ...

最新文章

  1. 快速幂运算and 快速乘运算
  2. 刚刚,我国智能科学技术最高奖揭晓!
  3. 主流浏览器新版本将不再支持TLS 1.0/1.1
  4. 【Kotlin】Kotlin 类的继承 三 ( super 关键字使用 | super@ 外部调用父类方法 | 子类选择性调用 父类 / 接口 方法 super )
  5. 制作碳排放强度的空间可视化_【科研成果】吴传清、宋子逸:长江经济带农业碳排放的时空差异特征分析...
  6. 【数据分析+建模案例】基于所给数据集对饭店流量指标进行预测
  7. cacti系统性能监控(CENTOS/UBUNTU)
  8. macos关闭软件更新小红点_MacOS和Windows哪个更适合你?
  9. 王朔《我的千岁寒》:可以看却无法看到
  10. html页面按钮删除一条数据库,需要添加一个删除按钮到一个HTML表格从数据库中删除记录与消息...
  11. 《BI那点儿事》数据流转换——聚合
  12. 《信号与系统学习笔记》—信号与系统(二)
  13. win10 linux声音,win10电脑突然没有声音的10种修复方法
  14. Windows下PHP各版本运行库vc9-vc14下载集合
  15. mac 命令修改dns服务器,MAC设置DNS的步骤
  16. 华为浏览器不能下载linux,H5下载手游页面,华为手机浏览器不兼容
  17. MongoDB一篇从入门到实战
  18. 易语言 图片插入超级列表框_新手教程!如何在PDF文件中插入图像
  19. 2022-03-06 近期的低劣的管理者的几点观察
  20. 植物大战僵尸2 服务器维护时间,植物大战僵尸2PVP商店多久更新一次

热门文章

  1. 解决IDEA和输入法切换快捷键Ctrl+Space(空格)冲突导致无法显示代码提示
  2. win10n网页如何保存为html,win10浏览器如何保存网页_win10浏览器怎么保存网页
  3. 你是编程中的“快枪手”还是“慢悠悠”?
  4. KDE-PIM(KDE小我信息对象)先容
  5. patch文件如何合并到源码目录中
  6. Windows CE 6.0 vs 7.0
  7. 侏罗纪世界为什么显示服务器超时,侏罗纪世界进化服务器无法访问解决方案推荐_侏罗纪世界进化全系统详解及上手指南推荐-魔盟网...
  8. layui取input name_layui列表如何取input框的值
  9. RK3568平台开发系列讲解(USB篇)USB线缆的要求
  10. 【算法】动态规划 背包问题 python