这个题,做出来的人很多,我感觉是数据不够强,我看了很多人的代码直接暴力也能过了,直接暴力如果数据够强的话肯定是时间超限,边缘数据不够强。如果和上次一样估计很多人的E会GG。我看到一位OIdalao的代码,认为这个是正确的解法,对每一道围墙进行hash处理,然后用二维的树状数组来解决这个问题。感觉博主已经写得简单易懂了。长了姿势

#include <bits/stdc++.h>
using namespace std;map<pair<pair<int, int>, pair<int, int> >, int>g;
int n, m, q;
long long c[2520][2520];
void R(int x, int y, long long z) {for (int i = x; i <= n; i += i & -i) {for (int j = y; j <= m; j += j & -j) {c[i][j] += z;}}
}long long G(int x, int y) {long long re = 0;for (int i = x; i > 0; i -= i & -i) {for (int j = y; j > 0; j -= j & -j) {re += c[i][j];}}return re;
}int rd() {return rand() << 15 | rand();
}
int main() {scanf("%d%d%d", &n, &m, &q);srand(time(0));for (int i = 0; i < 011; i++) {srand(rd());}for (int i = 0; i < q; i++) {int o, xa, xb, ya, yb;scanf("%d%d%d%d%d", &o, &xa, &ya, &xb, &yb);if (o == 1) {int u = rd();g[make_pair(make_pair(xa, ya), make_pair(xb, yb))] = u;R(xa, ya, u);R(xa, yb + 1, -u);R(xb + 1, ya, -u);R(xb + 1, yb + 1, u);} else if (o == 2) {int u = g[make_pair(make_pair(xa, ya), make_pair(xb, yb))];R(xa, ya, -u);R(xa, yb + 1, u);R(xb + 1, ya, u);R(xb + 1, yb + 1, -u);} else {long long va = G(xa, ya);long long vb = G(xb, yb);if (va == vb) {printf("Yes\n");} else {printf("No\n");}}}return 0;
}

Codeforces Round #439 (Div. 2) E. The Untended Antiquity (hash+数状数组)相关推荐

  1. Codeforces Round #439 (Div. 2) E. The Untended Antiquity 二维线段树||二维树状数组

    http://codeforces.com/contest/869/problem/E 题意:n*m的矩阵,q次操作,三种类型 类型1:给指定矩阵加上围栏 类型2:给指定矩阵去掉围栏 类型3:查询两点 ...

  2. Codeforces Round #439 (Div. 2) E. The Untended Antiquity

    E. The Untended Antiquity Problem Statement Adieu l'ami.     Koyomi is helping Oshino, an acquaintan ...

  3. Codeforces Round #439 (Div. 2) E. The Untended Antiquity(二维BIT)

    题意:在 n×m 的二维图上,有三种操作: 1 r1 c1 r2 c2 表示沿着 (r1, c1, r2, c2) 所表示的矩形的外边框建围墙.(其中 (r1, c1) 为矩形左上角,(r2, c2) ...

  4. codeforces 869 E. The Untended Antiquity(树状数组)

    题目链接:http://codeforces.com/contest/869/problem/E 题解:这题是挺好想到solution的但是不太好写,由于题目的特殊要求每个矩形不会重贴所以只要这两个点 ...

  5. Codeforces Round #439 (Div. 2) Problem C (Codeforces 869C) - 组合数学

    - This is not playing but duty as allies of justice, Nii-chan! - Not allies but justice itself, Onii ...

  6. Codeforces Round #439 (Div. 2)

    一句话题意: A:传送门 题意:给定两个长为\(n\)的数组\(a\),\(b\),令\(ans=\)有序对\((i,j)\)的个数使得\(a_i\ xor\ b_j\)在这\(2n\)个数中出现过, ...

  7. Codeforces Round #439 (Div. 2)C - The Intriguing Obsession(简单dp)

    传送门 题意 给出三个集合,每个集合的元素数量为a,b,c,现在需要连边,满足集合内元素不可达或最短路为3,求可行方案数 分析 设dp[i][j]为a集合元素为i个,b集合元素为j个的可行方案,易知( ...

  8. Codeforces Round #439 (Div. 2) A. The Artful Expedient

    A. The Artful Expedient Problem Statement Rock- Paper!     After Karen have found the deterministic ...

  9. 【Codeforces Round #439 (Div. 2) A】The Artful Expedient

    [链接] 链接 [题意] [题解] 暴力 [错的次数] 在这里输入错的次数 [反思] 在这里输入反思 [代码] #include <bits/stdc++.h> using namespa ...

最新文章

  1. 组合游戏系列5: 井字棋、五子棋AlphaGo Zero 算法实战
  2. kswapd0 挖矿_bioset linux_linux bioset 进程 腾讯云
  3. java 中 FtpClient 实现 FTP 文件上传、下载
  4. 机器学习简介及学习思维导图
  5. Virtual Studio 2013 每次加载程序(dll)缓慢的问题
  6. html中写meta会乱码,BeautifulSoup+Unicode,该死的html乱码,尽管在meta标记中指定了字符集...
  7. 《大数据分析原理与实践》一一导读
  8. HDOJ--2544--最短路
  9. (日常搬砖)windows 11 安装cython_bbox时,遇到问题‘error: Microsoft Visual C++ 14.0 or greater is required. ’解决方案
  10. 计算机硬件配置及安装,电脑硬件及电脑配置知识大全
  11. java技术简介英文_JAVA技术人员英文简历模板
  12. ARM嵌入式——堆栈寻址
  13. oracle bam教程,Oracle BAM原理简介
  14. 怎么确定K均值聚类中的K(基于matlab)
  15. python用turtle画七巧板_python之“七巧板”
  16. 计算机二级长春光华学院,长春光华学院排名2021 吉林排名第3全国排名第73
  17. java json 合并_java json 合并
  18. 领悟《信号与系统》之 非周期信号的傅里叶变换
  19. SBAS 电离层修正中的双线性插值方法
  20. 芯片后端开发基础知识(二)

热门文章

  1. 带你学习如何更好的使用uni-app(一)
  2. one coin,oneworld
  3. win18系统如何打开c语言,控制面板在哪里打开(Windows打开控制面板的方法)
  4. Android仿微信发图片的样式,做IM的同学的病有救了
  5. 求一个数的所有因数+质因数分解【数论】
  6. 爬山法求解八皇后问题的全部解法
  7. 网络维护工程师的要求是什么?
  8. CSS尺寸单位px、em、rem、vw、vh以及%的区别
  9. Markdown的使用(富文本编辑)
  10. c++逆天改命进阶--二叉树练习题