1、题目大意: 就是给一个n×m的方格,然后一些平面上的 求和 修改操作

2、分析:二维树状数组裸题

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int C[110][310][310];
int a[310][310];
int n, m;
inline void add(int c, int x, int y, int z){
    for(; x <= n; x += (x & -x)){
        int yy = y;
        for(; yy <= m; yy += (yy & -yy)){
            C[c][x][yy] += z;
        }
    }
    return;
}
inline int query(int c, int x, int y){
    int res = 0;
    for(; x > 0; x -= (x & -x)){
        int yy = y;
        for(; yy > 0; yy -= (yy & -yy)){
            res += C[c][x][yy];
        }
    }
    return res;
}
int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            int c; scanf("%d", &c);
            add(c, i, j, 1); a[i][j] = c;
        }
    }
    int Q;
    scanf("%d", &Q);
    while(Q --){
        int op, x1, y1, x2, y2, c;
        scanf("%d", &op);
        if(op == 1){
            scanf("%d%d%d", &x1, &y1, &c);
            add(a[x1][y1], x1, y1, -1);
            add(c, x1, y1, 1);
            a[x1][y1] = c;
        }
        else{
            scanf("%d%d%d%d%d", &x1, &x2, &y1, &y2, &c);
            printf("%d\n", query(c, x2, y2) - query(c, x1 - 1, y2) - query(c, x2, y1 - 1) + query(c, x1 - 1, y1 - 1));
        }
    }
    return 0;
} 

BZOJ1452——[JSOI2009]Count的更多相关文章

  1. [bzoj1452][JSOI2009]Count(树状数组)

    1452: [JSOI2009]Count Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 2057  Solved: 1216[Submit][Stat ...

  2. BZOJ1452 [JSOI2009]Count 【树套树 (树状数组)】

    1452: [JSOI2009]Count Time Limit: 10 Sec  Memory Limit: 64 MB Submit: 2693  Solved: 1574 [Submit][St ...

  3. BZOJ1452 [JSOI2009]Count [2017年4月计划 树状数组02]

    1452: [JSOI2009]Count Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 2419  Solved: 1403[Submit][Stat ...

  4. BZOJ1452 [JSOI2009]Count

    Description Input Output Sample Input Sample Output 1 2 HINT 正解:二维树状数组 解题报告: 这是一道送肉题.二维树状数组直接维护每种颜色的 ...

  5. bzoj1452 [JSOI2009]Count ——二维树状数组

    中文题面,给你一个矩阵,每一个格子有数字,有两种操作. 1. 把i行j列的值更改 2. 询问两个角坐标分别为(x1,y1) (x2,y2)的矩形内有几个值为z的点. 这一题的特点就是给出的z的数据范围 ...

  6. 【二维树状数组】bzoj1452 [JSOI2009]Count

    权值的种类只有100种,对每种开个二维BIT,然后是经典操作. #include<cstdio> using namespace std; ][]; struct BIT_2D { ][] ...

  7. 【BZOJ1452】[JSOI2009]Count(树状数组)

    [BZOJ1452][JSOI2009]Count(树状数组) 题面 BZOJ 洛谷 题解 数据范围这么小?不是对于每个颜色开一个什么东西记一下就好了吗. 然而我不会二维树状数组? 不存在的,凭借多年 ...

  8. [bzoj1452][JSOI2009]Count_树状数组

    Count bzoj-1452 JSOI-2009 题目大意:请维护一个平面内的数据结构,支持:单点修改,查询矩形内给定权值出现次数. 注释:$1\le n,m\le 300$,$1\le Q \le ...

  9. 【BZOJ-1452】Count 树状数组 套 树状数组

    1452: [JSOI2009]Count Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 1769  Solved: 1059[Submit][Stat ...

随机推荐

  1. maven的环境搭建

    maven环境快速搭建 最近,开发中要用到maven,所以对maven进行了简单的学习. .关于maven是什么东东,请参考其它文章. ----------------准备工作------------ ...

  2. css011 表格和表单的格式化

    css011 表格和表单的格式化 一.    让表格专司其职    Html中创建一个三行三列的表格 <table> <caption align="bottom" ...

  3. c++ operator

    这篇博文是以前很久写的,贴在我的早期一个blog中,今天google一下,发现还真有不少人转载,可惜并不注明出处.那时觉得operator比较好玩.C++有时它的确是个耐玩的东东.operator它有 ...

  4. bootstrap弹框

    http://v3.bootcss.com/javascript/#modals 参考bootstrap官网 模态框做php后端 前端一直不行,但是很多时候 用到ajax都要用到弹框,一直在代码里面找 ...

  5. CentOS7 Mini安装Oracle(图形化安装)

    以下操作在root用户下进行 1.mini版centos7没有ifconfig指令,可以如下操作 [root@localhost ~]# yum upgrade [root@localhost ~]# ...

  6. Python学习笔记——文件写入和读取

    1.文件写入 #coding:utf-8 #!/usr/bin/env python 'makeTextPyhton.py -- create text file' import os ls = os ...

  7. Java数据库——PreparedStatement接口

    PreparedStatement接口是Statement的子接口,属于预处理操作,与直接使用Statement不同的是,PreparedStatement在操作时,是先在数据表中准备好了一条SQL语 ...

  8. PHP_php.ini_说明详解

    这个文件必须命名为''php.ini''并放置在httpd.conf中的PHPIniDir指令指定的目录中.最新版本的php.ini可以在下面两个位置查看:http://cvs.php.net/vie ...

  9. Unity Sprite Atlas Compression

    http://forum.unity3d.com/threads/2d-sprite-packer-and-pvrtc.218633/ http://docs.unity3d.com/Manual/S ...

  10. autofac获取全局Container

    _UserService = ((IContainerProviderAccessor)HttpContext.Current.ApplicationInstance).ContainerProvid ...