二维前缀和 codeforces 832C
来源:互联网 发布:诛仙手游破凶辅助软件 编辑:程序博客网 时间:2024/06/05 21:08
#include <iostream> #include <cstdio> #include <cstring > #include <iostream> using namespace std; int mp[102][102][11]; int sum[102][102][11]; int main() { int n,q,c; while(~scanf("%d%d%d",&n,&q,&c)) { memset(mp,0,sizeof(mp)); for(int i = 0; i < n; i++) { int x,y,s; scanf("%d%d%d",&x,&y,&s); mp[x][y][s]++; //记录地图 在(x,y)上 亮度为s的星星的个数 这里因为星星可以重叠在一个点 要用++ } memset(sum,0,sizeof(sum)); for(int k = 0; k <= c; k++) { for(int i = 1; i <= 100; i++) { //二维前缀和 for(int j = 1; j <= 100; j++) { sum[i][j][k] = sum[i-1][j][k]+sum[i][j-1][k]-sum[i-1][j-1][k]+mp[i][j][k]; //处理亮度为k的星星在(1,1)到(i,j)矩阵内的个数 } } } for(int i = 0; i < q; i++) { int t,x1,y1,x2,y2; scanf("%d%d%d%d%d",&t,&x1,&y1,&x2,&y2); int ans = 0; int ans1; for(int k = 0; k <= c; k++) { ans1 = (k+t)%(c+1); // 计算亮度为k的星星在t秒后的亮度 int num = sum[x2][y2][k]-sum[x1-1][y2][k]-sum[x2][y1-1][k]+sum[x1-1][y1-1][k]; //计算 (x1,y1)到(x2,y2)矩阵内亮度为k的星星的个数 ans1 *= num; ans += ans1; } printf("%d\n",ans); } } }
阅读全文
0 0
- 二维前缀和 codeforces 832C
- codeforces 835C(二维前缀和)
- Codeforces 611C:New Year and Domino 二维前缀和
- Codeforces 611C:New Year and Domino 二维前缀和
- codeforces 835C Star sky (二维数组前缀和)
- Codeforces 853C Star sky(二维前缀和)
- codeforces Star sky(二维前缀和)
- Codeforces Round #427 (Div. 2)-C. Star sky(二维前缀和)
- Codeforces Round #427 (Div. 2) C. Star sky 二维前缀和
- Codeforces 835C Star sky【思维+暴力预处理二维前缀和】
- Codeforces Round #427 (Div. 2) C.Star sky【模拟、二维前缀和】
- codeforces835 b贪心 c 二维前缀和
- Codeforces 828B Black Square【暴力枚举+二维前缀和】
- Codeforces 846D Monitor(二维前缀和)
- Codeforces 106D Treasure Island【思维+二维前缀和】
- codeforces 846D (二分+二维前缀和)Monitor
- Codeforces 460C Present 二分+前缀和
- 二维前缀和
- [Visual Studio]MFC游戏开发之回合制对战系统二_by书訢
- Ajax的Result工具类
- oracle函数与条件表达式
- JQuery入门(一)
- 浏览器对象模型BOM
- 二维前缀和 codeforces 832C
- Laravel Composer Package 开发简明教程
- zookeeper(2) zookeeper客户端ZkClient入门
- 【KMP】POJ2752 Seek the Name, Seek the Fame
- QT UI文件生成头文件
- Vue.js 目录结构
- 判断B数组是否为A数组的子集(有重复、无序)
- 墨菲定律
- JavaScript-取非行间样式(不能用来设置)