题目链接 题意 : 给你每个柿子树的位置,给你已知长宽的矩形,让这个矩形包含最多的柿子树.输出数目 思路 :数据不是很大,暴力一下就行,也可以用二维树状数组来做. #include <stdio.h> #include <string.h> #include <iostream> using namespace std ; ][] ; int main() { int N ,S,T ,W,H; while(scanf("%d",&N) !=…
P4054 [JSOI2009]计数问题 题目描述 一个n*m的方格,初始时每个格子有一个整数权值.接下来每次有2种操作: 改变一个格子的权值: 求一个子矩阵中某种特定权值出现的个数. 输入输出格式 输入格式: 第一行有两个数N,M. 接下来N行,每行M个数,第i+1行第j个数表示格子(i,j)的初始权值. 接下来输入一个整数Q. 之后Q行,每行描述一个操作. 操作1:"1 x y c"(不含双引号).表示将格子(x,y)的权值改成c(1<=x<=n,1<=y<…
对每种颜色开一个二维树状数组 #include<cstdio> #include<algorithm> using namespace std; ; ][maxn][maxn],c[maxn][maxn],Q,n,m,k,x,y,xx,yy,col; inline void read(int &k){ k=; ; char c=getchar(); ),c=getchar(); +c-',c=getchar(); k*=f; } inline void add(int co…
<题目链接> 题目大意: 给你一个H*W的矩阵,再告诉你有n个坐标有点,问你一个w*h的小矩阵最多能够包括多少个点. 解题分析:二维树状数组模板题. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; +; int tr[M][M]; int n,W,H,w,h; int lowbit(int x){return x&(-x);} void ad…
Get Many Persimmon Trees Time Limit:1000MS    Memory Limit:30000KB    64bit IO Format:%I64d & %I64u SubmitStatusPracticePOJ 2029 Description Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aizu for a long time in…
Description Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aizu for a long time in the 18th century. In order to reward him for his meritorious career in education, Katanobu Matsudaira, the lord of the domain of…
<题目链接> 题目大意: 给出一个初始值全为0的矩阵,对其进行两个操作. 1.给出一个子矩阵的左上角和右上角坐标,这两个坐标所代表的矩阵内0变成1,1变成0. 2.查询某个坐标的点的值. 解题分析: 二维树状数组单点查询经典题.首先本题可以先从一维的情况推广,假设要使区间内[L,R]中所有的数字异或,我们应该在L处+1,并且在R+1处+1,单点查询的时候,直接查询这个点的前缀%2的值即可.因为,我们要明确,更新操作只能对[L,R]中的元素起作用,而不能影响其他区间的元素.所以,对于那些小于L的…
二维树状数组 单点更新区间查询 模板 从零开始借鉴http://www.2cto.com/kf/201307/227488.html #include<stdio.h> #include<string.h> #define N 1100 int c[N][N],visit[N][N],n; int number(int x) { return x&-x; } void insert(int x,int y,int z) { int i,j; for(i=x;i<=N;…
Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 14489   Accepted: 6735 Description Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The…
Description Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aizu for a long time in the 18th century. In order to reward him for his meritorious career in education, Katanobu Matsudaira, the lord of the domain of…