题目链接

  这题就是考虑我们有这样一个情况

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbcAAAGCCAIAAADsQhqiAAAgAElEQVR4Ae3cbWxb133HcT5cPouUZctSJMeSKz+kfui8zBhS1yugLomXok2CvAiGLIhTbOgS7E0yLDAwrFiarW+6bMDyZkXWregadMECDEmQdu1Sp07TtHCAKUXWxPHkh1p0bFmWZYkUKVJ83F+ho6qSeEzGou85PF9BUKh7ru79/z/n6Od7SSrearXq4QMBBBBAoI6Ar852NiOAAAIILAiQkqwDBBBAQCVASqp0GEMAAQRISdYAAgggoBIgJVU6jCGAAAKkJGsAAQQQUAmQkiodxhBAAAFSkjWAAAIIqARISZUOYwgggAApyRpAAAEEVAKkpEqHMQQQQICUZA0ggAACKgFSUqXDGAIIIEBKsgYQQAABlQApqdJhDAEEECAlWQMIIICASoCUVOkwhgACCJCSrAEEEEBAJUBKqnQYQwABBEhJ1gACCCCgEiAlVTqMIYAAAqQkawABBBBQCZCSKh3GEEAAAVKSNYAAAgioBEhJlQ5jCCCAACnJGkAAAQRUAqSkSocxBBBAgJRkDSCAAAIqAVJSpcMYAgggQEqyBhBAAAGVgKMaZAwBYwXGxq/8ZOTkqeTkVCobj4a2DWz89Kc+sWdbv7ENUbhrAt5qterayTkxAq0R+M733vrGC2+sPPadn955+Et3dkRDK4fYgkA9AVKyngzbjRQoFEt//vf/+fb7Sal+b+nyjtKVrsr8rNc55+88Fuwrebx93Z3ffPLBDZ0xI9ujaDcESEk31DlnywT+5cWf/euLP49US/fnR3eVppaeZ9IX/U5kp3yVK8q/+bMvLh3iMQIKAV69UeAwZJjAybFLEpFS9MqIlI0bK3N/OvdLCdAfHXv/jZGThvVGue4JkJLu2XPmtRb4ydsL2Sc32suuIhfPE68W7iiMybf/9eZ7ixt5gIBagJRU+zBqkoC8oi3l7i1eUhS9ozQjo6Njqn0UP86QhQJavxNIXqaUFystnBVavh6BjZWc4sflvtvxVMYvp/YfelqxG0M3TOALn93zlS9//oad7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wc+Z0pGu0nbV5a1Wq3Z1TLcrBOSpyWe+++PZuavvnpGXa2oXYhI3EpGHvnjbip/QesO7py7IE5Rj41dqVcqLOeNyV10AAAFUSURBVLmPsjIeDT324O/LJafWDVCcZgKkpGYT4lI5U6nsN15442Ty0ujYJSlBbsPlDQYGXUWuZPuP//6fN94+LYlZKC68gi/t7Nm60FFHlD/iXqnFFpUAKanSYQwBBBDgeUnWAAIIIKASICVVOowhgAACpCRrAAEEEFAJkJIqHcYQQAABUpI1gAACCKgESEmVDmMIIIAAKckaQAABBFQCpKRKhzEEEECAlGQNIIAAAioBUlKlwxgCCCBASrIGEEAAAZUAKanSYQwBBBAgJVkDCCCAgEqAlFTpMIYAAgiQkqwBBBBAQCVASqp0GEMAAQRISdYAAgggoBIgJVU6jCGAAAKkJGsAAQQQUAmQkiodxhBAAAFSkjWAAAIIqARISZUOYwgggAApyRpAAAEEVAKkpEqHMQQQQICUZA0ggAACKgFSUqXDGAIIIEBKsgYQQAABlcD/A5Wyipi9JzwiAAAAAElFTkSuQmCCAA==" alt="" width="188" height="165" />

  然后我们试图很方便地求出第三行第二个和第三个常青树之间所有点上下常青树的组合。

  考虑使用树状数组,一开始把数组平放在最底下,然后往上推。

#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cctype>
#include<cstring>
#define maxn 200020
#define maxd 12
#define mod 2147483648
using namespace std;
inline long long read(){
long long num=,f=;
char ch=getchar();
while(!isdigit(ch)){
if(ch=='-') f=-;
ch=getchar();
}
while(isdigit(ch)){
num=num*+ch-'';
ch=getchar();
}
return num*f;
} struct Tree{
long long x,y;
bool operator <(const Tree a)const{
if(x!=a.x) return x<a.x;
return y<a.y;
}
}q[maxn]; long long s[maxn*],cnt;
long long c[maxn][maxd]; long long tree[maxn*];
inline long long low(long long x){ return x&(-x); } inline void add(long long pos,long long lim,long long num){
while(pos<=lim){
tree[pos]+=num;
tree[pos]%=mod;
pos+=low(pos);
}
return;
} inline long long query(long long pos){
long long ans=;
while(pos){
ans+=tree[pos];
ans%=mod;
pos-=low(pos);
}
return ans;
} long long up[maxn],down[maxn];
long long lef[maxn],rig[maxn]; int main(){
long long m=read()+,n=read()+;
long long e=read();
for(long long i=;i<=e;++i){
q[i]=(Tree){read(),read()};
swap(q[i].x,q[i].y);
s[++cnt]=q[i].x; s[++cnt]=q[i].y;
}
sort(s+,s+cnt+);
long long size=unique(s+,s+cnt+)-s-;
for(long long i=;i<=e;++i){
q[i].x=lower_bound(s+,s+size+,q[i].x)-s;
q[i].y=lower_bound(s+,s+size+,q[i].y)-s;
}
sort(q+,q+e+);
for(long long i=;i<=e;++i){
up[q[i].y]++;
rig[q[i].x]++;
}
long long d=read();
for(long long i=;i<=e;++i) c[i][]=;
for(long long i=;i<=e;++i)
for(long long j=;j<=d;++j) c[i][j]=(c[i-][j]+c[i-][j-])%mod;
long long ans=;
for(long long i=;i<=e;++i){
if(q[i].x==q[i-].x&&i!=){
//printf("i=%d\nxi=%d yi=%d\n%d %d %d %d\n",i,q[i].x,q[i].y,lef[q[i].x],rig[q[i].x],query(q[i].y),query(q[i].y-q[i-1].y));
ans+=c[lef[q[i].x]][d]*c[rig[q[i].x]][d]*(query(q[i].y-)-query(q[i-].y))%mod;
} up[q[i].y]--; down[q[i].y]++;
lef[q[i].x]++; rig[q[i].x]--;
add(q[i].y,size,c[up[q[i].y]][d]*c[down[q[i].y]][d]-query(q[i].y)+query(q[i].y-));
}
printf("%lld\n",(ans%mod+mod)%mod);
return ;
}

【Luogu】P2154虔诚的墓主人(树状数组)的更多相关文章

  1. P2154 [SDOI2009]虔诚的墓主人 树状数组

    https://www.luogu.org/problemnew/show/P2154 题意 在一个坐标系中,有w(1e5)个点,这个图中空点的权值是正上,正下,正左,正右各取k个的排列组合情况.计算 ...

  2. BZOJ-1227 虔诚的墓主人 树状数组+离散化+组合数学

    1227: [SDOI2009]虔诚的墓主人 Time Limit: 5 Sec Memory Limit: 259 MB Submit: 914 Solved: 431 [Submit][Statu ...

  3. [luogu2154 SDOI2009] 虔诚的墓主人(树状数组+组合数)

    传送门 Solution 显然每个点的权值可以由当前点上下左右的树的数量用组合数\(O(1)\)求出,但这样枚举会T 那么我们考虑一段连续区间,对于一行中两个常青树中间的部分左右树的数量一定,我们可用 ...

  4. Bzoj 1227: [SDOI2009]虔诚的墓主人 树状数组,离散化,组合数学

    1227: [SDOI2009]虔诚的墓主人 Time Limit: 5 Sec  Memory Limit: 259 MBSubmit: 895  Solved: 422[Submit][Statu ...

  5. [luogu P2184] 贪婪大陆 [树状数组][线段树]

    题目背景 面对蚂蚁们的疯狂进攻,小FF的Tower defence宣告失败……人类被蚂蚁们逼到了Greed Island上的一个海湾.现在,小FF的后方是一望无际的大海, 前方是变异了的超级蚂蚁. 小 ...

  6. LUOGU P2617 Dynamic Rankings(树状数组套主席树)

    传送门 解题思路 动态区间第\(k\)大,树状数组套主席树模板.树状数组的每个位置的意思的是每棵主席树的根,维护的是一个前缀和.然后询问的时候\(log\)个点一起做前缀和,一起移动.时空复杂度\(O ...

  7. LUOGU P2344 奶牛抗议 (树状数组优化dp)

    传送门 解题思路 树状数组优化dp,f[i]表示前i个奶牛的分组的个数,那么很容易得出$f[i]=\sum\limits_{1\leq j\leq i}f[j-1]*(sum[i]\ge sum[j- ...

  8. luogu SP8093 后缀自动机+树状数组+dfs序

    这题解法很多,简单说几个: 1. 线段树合并,时间复杂度是 $O(nlog^2n)$ 的. 2. 暴力跳 $fail,$ 时间复杂度 $O(n\sqrt n),$ 比较暴力. 3. 建立后缀树后在 $ ...

  9. luogu P1908 逆序对 |树状数组

    题目描述 猫猫TOM和小老鼠JERRY最近又较量上了,但是毕竟都是成年人,他们已经不喜欢再玩那种你追我赶的游戏,现在他们喜欢玩统计.最近,TOM老猫查阅到一个人类称之为"逆序对"的 ...

随机推荐

  1. tcp客户端socket

    import socket # 和udp的区别显而易见,udp发送和接收的是一个元祖,因为udp是不建立连接的,只有得到了对方的端口和ip才能进行沟通. # 而tcp不是,tcp发送和接受的是一个字符 ...

  2. Servlet学习笔记01——什么是servlet?

    1.什么是Servlet? sun公司制订的一种用来扩展web服务器功能的组件规范. (1)扩展web服务器功能 早期的web服务器(apache web server,iis) 只能处理静态资源的请 ...

  3. 【Effective c++ 读书笔记】条款01 视 C++ 为一个语言联邦

    一开始,C++只是 C 加上一些面向对象的特性.C++最初的名称 C with Classes 也反映了这个血缘关系. 但是,现在,当这个语言逐渐成熟,它变得更活跃更无拘束,更大胆冒险,开始接受不同于 ...

  4. php生成微信小程序二维码源码

    目前有3个接口可以生成小程序码,开发者可以根据自己的需要选择合适的接口.第一步:获取   access_token public function getWxAccessToken(){ $appid ...

  5. 准备篇(二)C语言

    因为C语言部分打算单独维护,所以 目录: 1. C语言基础篇(零)gcc编译和预处理 2. C语言基础篇(一)关键字 3. C语言基础篇(二)运算符 4. C语言指针篇(一)指针与指针变量 5. C语 ...

  6. 小明的存钱计划 南阳acm54

    小明的存钱计划 时间限制:3000 ms  |  内存限制:65535 KB 难度:2 描述 小明的零花钱一直都是自己管理.每个月的月初妈妈给小明300元钱,小明会预算这个月的花销,并且总能做到实际花 ...

  7. zookeeper: web ui工具的安装

    zookeeper官方没有提供web用户界面,这使很多人在使用zookeeper(动物管理员)同时,并不是很容易的理解zookeeper的数据结构,还好淘宝有位大神用Nodejs写了一个web的ui工 ...

  8. 16,docker入门

      在学一门新知识的时候,超哥喜欢提问,why?what?how? wiki资料 什么是docker Docker 最初是 dotCloud 公司创始人 Solomon Hykes 在法国期间发起的一 ...

  9. 理解Queue队列中join()与task_done()的关系

    在网上大多关于join()与task_done()的结束原话是这样的: Queue.task_done() 在完成一项工作之后,Queue.task_done()函数向任务已经完成的队列发送一个信号 ...

  10. javascript数组&省市联动分别用js数组和JSON实现

    1.定义数组的三种方式: **数组可以存放不同的数据类型   第一种: var arr=[1,2,3];   var arr=[1,"2",true];   第二种: 使用内置对象 ...