Star sky CodeForces - 835C
用一个三维数组cnt[x][y][k]表示从(1, 1)到(x, y)亮度为k的个数,然后查询的时候就是对于每一个亮度,计算出这个亮度t秒后的亮度和当前这个亮度的个数,答案就是他们的乘积, 然后遍历每种亮度就可以算出答案
#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<stack>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lowbit(x) (x & (-x)) typedef unsigned long long int ull;
typedef long long int ll;
const double pi = 4.0*atan(1.0);
const int inf = 0x3f3f3f3f;
const int maxn = ;
const int maxm = ;
const int mod = 1e9+;
using namespace std; int n, m;
int T, tol;
int cnt[maxn][maxn][maxn/]; void init() {
memset(cnt, , sizeof cnt);
} int main() {
init();
int q, c;
scanf("%d%d%d", &n, &q, &c);
int mx=, my=;
int x, y, s;
for(int i=; i<=n; i++) {
scanf("%d%d%d", &x, &y, &s);
cnt[x][y][s]++;
mx = max(mx, x);
my = max(my, y);
}
for(int i=; i<=; i++) {
for(int j=; j<=; j++) {
for(int k=; k<=c; k++) {
cnt[i][j][k] = cnt[i][j][k] + cnt[i-][j][k] + cnt[i][j-][k] - cnt[i-][j-][k];
}
}
}
int t, x1, y1, x2, y2;
while(q--) {
scanf("%d%d%d%d%d", &t, &x1, &y1, &x2, &y2);
int ans = ;
for(int k=; k<=c; k++) {
int tmp = (k+t) % (c+);
int cx = cnt[x2][y2][k] - cnt[x1-][y2][k] - cnt[x2][y1-][k] + cnt[x1-][y1-][k];
ans += tmp * cx;
}
printf("%d\n", ans);
}
return ;
}
Star sky CodeForces - 835C的更多相关文章
- Codeforces Round #427 (Div. 2) Problem C Star sky (Codeforces 835C) - 前缀和
The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinat ...
- CodeForces 835C - Star sky | Codeforces Round #427 (Div. 2)
s <= c是最骚的,数组在那一维开了10,第八组样例直接爆了- - /* CodeForces 835C - Star sky [ 前缀和,容斥 ] | Codeforces Round #4 ...
- Codeforces Round #427 (Div. 2) [ C. Star sky ] [ D. Palindromic characteristics ] [ E. The penguin's game ]
本来准备好好打一场的,然而无奈腹痛只能带星号参加 (我才不是怕被打爆呢!) PROBLEM C - Star sky 题 OvO http://codeforces.com/contest/835/p ...
- 动态规划:Codeforces Round #427 (Div. 2) C Star sky
C. Star sky time limit per test2 seconds memory limit per test256 megabytes inputstandard input outp ...
- Star sky 二维前缀和
C. Star sky time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...
- Codeforces 835C - Star sky - [二维前缀和]
题目链接:http://codeforces.com/problemset/problem/835/C 题意: 在天空上划定一个直角坐标系,有 $n$ 颗星星,每颗星星都有坐标 $(x_i,y_i)$ ...
- 【Codeforces Round #427 (Div. 2) C】Star sky
[Link]:http://codeforces.com/contest/835/problem/C [Description] 给你n个星星的坐标(xi,yi); 第i个星星在第t秒,闪烁值变为(s ...
- C. Star sky 二维前缀和
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- CF Round #427 (Div. 2) C. Star sky [dp]
题目链接就长这样子? time limit per test 2 seconds memory limit per test 256 megabytes Description The Carte ...
随机推荐
- Linux kernel support docker storage driver aufs
How to make docker use aufs in CentOS 7? - Server Faulthttps://serverfault.com/questions/650208/how- ...
- xmanager 乱码
xmanager连接后中文显示乱码 - 程序员CC - 博客园http://www.cnblogs.com/aomidata/p/3445075.html Xshell 为什么会出现中文乱码?-Xma ...
- C#设计模式之1:策略模式
首先需要说明的是该系列的所有内容都是基于headfirst设计模式来描述的.因为我之前也看过不少关于设计模式的书,还是发现这本最好,因为这本书里面给出的例子是最贴切实际的.不说了,开始这个系列吧! 策 ...
- AngularJS基于MVC的复杂操作案例
AngularJS基于MVC的复杂操作案例 <!DOCTYPE html> <html> <head> <meta charset="UTF-8&q ...
- 数组中元素累加 reduce
例: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8& ...
- Flutter上拉加载下拉刷新---flutter_easyrefresh
前言 Flutter默认不支持上拉加载,下拉刷新也仅仅支持Material的一种样式.Android开发使用过SmartRefreshLayout的小伙伴都知道这是一个强大的刷新UI库,集成了很多出色 ...
- 用户认证--------------auth模块
一.auth模块 from django.contrib import auth 1 .authenticate() :验证用户输入的用户名和密码是否相同 提供了用户认证,即验证用户名以及密码是否 ...
- python之路--进程内容补充
一. 进程的其他方法 进程id, 进程名字, 查看进程是否活着(is_alive()), terminate()发送结束进程的信号 import time import os from multipr ...
- Centos rpm包安装PHP所需包
yum -y install php php-devel php-fpm php-xml php-pdo php-ldap php-mysql
- Delphi之TComponent类
TComponent类 TComponent类直接由TPersistent派生.TComponent的独特特征是它的属性能够在设计期间通过ObjectInspector来控制,能够拥有其他组件.非可视 ...