Codeforces Round #427 (Div. 2) C. Star sky
来源:互联网 发布:赛博朋克2077 知乎 编辑:程序博客网 时间:2024/06/07 17:37
水平较水,想了老久,都结束了,才发现数据这么小,打个表预处理下不就好了。然后才想到,表怎么打?真是傻了
去看了看别人怎么打的。。。
光照强度每c+1轮循环一次,c<=10,共循环c+1轮,把每轮的都打出来,然后O(1)查询。。。
#include <bits/stdc++.h>using namespace std;struct star{ int x,y,s;};const int MAXN = 1e5+10;int table[15][110][110];star stars[MAXN];int n,q,c;int main(){ ios::sync_with_stdio(false); cin >> n >> q >> c; for(int i = 0; i < n; ++i) cin >> stars[i].x >> stars[i].y >> stars[i].s; for(int t = 0; t <= c; ++t) { for(int i = 0; i < n; ++i) table[t][stars[i].x][stars[i].y] += stars[i].s; for(int i = 1; i < 110; ++i) for(int j = 1; j < 110; ++j) table[t][i][j] += table[t][i][j-1]; for(int i = 1; i < 110; ++i) for(int j = 1; j < 110; ++j) table[t][j][i] += table[t][j-1][i]; for(int i = 0; i < n; ++i) stars[i].s = (stars[i].s+1)%(c+1); } int t,x1,y1,x2,y2; while(q--) { cin >> t >> x1 >> y1 >> x2 >> y2; t %= (c+1); int res = table[t][x2][y2]-table[t][x1-1][y2] -table[t][x2][y1-1]+table[t][x1-1][y1-1]; cout << res << endl; } return 0;}
阅读全文
0 0
- C. Star sky(Codeforces Round #427 (Div. 2) C)
- Codeforces Round #427 (Div. 2)C. Star sky
- Codeforces Round #427 (Div. 2) C. Star sky
- Codeforces Round #427 (Div. 2)-C. Star sky
- Codeforces Round #427 (Div. 2)C. Star sky(dp)
- Codeforces Round #427 (Div. 2) C. Star sky
- 动态规划:Codeforces Round #427 (Div. 2) C Star sky
- Codeforces Round #427 (Div. 2) C. Star sky
- Codeforces Round #427 (Div. 2) C. Star sky
- Codeforces Round #427 (Div. 2)-C. Star sky(二维前缀和)
- Codeforces Round #427 (Div. 2)C. Star sky 暴力D. Palindromic characteristics
- Codeforces Round #427 (Div. 2) C. Star sky 二维前缀和
- Codeforces Round #427 (Div. 2) C. Star sky(前缀和)
- Codeforces Round #427 (Div. 2) C. Star sky(前缀和)
- Codeforces Round #427 (Div. 2) C.Star sky【模拟、二维前缀和】
- Codeforces Round #427 (Div. 2) A. Key races B. The number on the board C. Star sky
- (状态方程, 数学)Codeforces Round #427 C. Star sky
- C. Star sky Codeforces
- 返回表中的属性值
- Codeforces835A Key races
- Python网络爬虫的网站实例
- java中冒号:的用法
- mysql for mac tar安装
- Codeforces Round #427 (Div. 2) C. Star sky
- Logstash详解之——input模块
- Android工具类库
- 360插件化Replugin爬坑之路
- RVM算法的matlab实现
- Spring IOC控制反转
- 修改表中数据
- android 计划
- Android Studio 使用小技巧和快捷键