题面:https://www.cnblogs.com/Juve/articles/11679226.html

梦境:

其实还是挺水的,排序错了过不了样例,打了个二分图匹配就跑了

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#define int long long
using namespace std;
const int MAXN=2e5+;
int n,m,b[MAXN],ans=;
struct node{
int l,r;
friend bool operator < (node p,node q){
return p.r==q.r?p.l<q.l:p.r<q.r;
}
}a[MAXN];
multiset<int>s;
signed main(){
scanf("%lld%lld",&n,&m);
for(int i=;i<=n;++i)
scanf("%lld%lld",&a[i].l,&a[i].r);
sort(a+,a+n+);
for(int i=;i<=m;++i){
scanf("%lld",&b[i]);
s.insert(b[i]);
}
for(int i=;i<=n;++i){
multiset<int>::iterator it=s.lower_bound(a[i].l);
if(it!=s.end()&&(*it)<=a[i].r){
++ans;
s.erase(it);
}
}
printf("%lld\n",ans);
return ;
}

玩具:神仙dp,

颓的题解和方程

令f[i][j]表示有i个点的树,深度不超过j的概率,g[i][j]表示有i个点的森林,深度不超过j的概率,

f[i][j]=g[i-1][j-1](j!=0) f[0][1]=1;

$g[i][j]=\sum\limits_{k=1}^{i}f[k][j]*g[i-k][j]*inv[i]$

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define int long long
using namespace std;
const int MAXN=;
int n,mod,inv[MAXN],ans=,g[MAXN][MAXN],f[MAXN][MAXN];
signed main(){
scanf("%lld%lld",&n,&mod);
inv[]=inv[]=;
for(int i=;i<=n;++i) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
for(int i=;i<=n;++i) g[][i]=;
for(int i=;i<=n;++i){
for(int j=;j<=n;++j){
if(j) f[i][j]=g[i-][j-];
else if(i==) f[i][j]=;
for(int k=;k<=i;++k)
g[i][j]=(g[i][j]+1ll*f[k][j]*g[i-k][j]%mod*inv[i]%mod)%mod;
}
}
for(int i=;i<=n;++i){
ans=(ans+1ll*(f[n][i]-f[n][i-]+mod)%mod*i%mod)%mod;
}
printf("%lld\n",ans);
return ;
}

飘雪圣域:

主席树,树状数组,莫队都可以过

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define re register
using namespace std;
const int MAXN=2e5+5;
int n,q;
vector<int>mp[MAXN];
int tot=0,root[MAXN];
struct node{
int ls,rs,val;
}tr[MAXN*30];
void build(int &k,int l,int r){
k=++tot;
if(l==r) return ;
int mid=(l+r)>>1;
build(tr[k].ls,l,mid);
build(tr[k].rs,mid+1,r);
}
void insert(int &now,int pre,int l,int r,int pos){
now=++tot;
tr[now]=tr[pre],++tr[now].val;
if(l==r) return ;
int mid=(l+r)>>1;
if(pos<=mid) insert(tr[now].ls,tr[pre].ls,l,mid,pos);
else insert(tr[now].rs,tr[pre].rs,mid+1,r,pos);
}
int query(int x,int y,int l,int r,int opl,int opr){
if(opl<=l&&r<=opr) return tr[y].val-tr[x].val;
int mid=(l+r)>>1,res=0;
if(opl<=mid) res+=query(tr[x].ls,tr[y].ls,l,mid,opl,opr);
if(opr>mid) res+=query(tr[x].rs,tr[y].rs,mid+1,r,opl,opr);
return res;
}
signed main(){
scanf("%d%d",&n,&q);
for(int i=1,u,v;i<n;++i){
scanf("%d%d",&u,&v);
mp[min(u,v)].push_back(max(u,v));
}
for(int i=1;i<=n;++i){
root[i]=root[i-1];
int N=mp[i].size();
for(int j=0;j<N;++j){
insert(root[i],root[i],1,n,mp[i][j]);
}
}
while(q--){
int l,r;
scanf("%d%d",&l,&r);
printf("%d\n",r-l+1-query(root[l-1],root[r],1,n,l,r));
}
return 0;
}

csps模拟测试74梦境,玩具,飘雪圣域题解的更多相关文章

  1. [CSP-S模拟测试74]题解

    A.梦境 如果不用去重一定要用Multiset……挂30分算是出题人手下留情了. 贪心.把点排序,区间按右端点递增排序.依次考虑每个区间,取能选的最靠左的点即可.multiset维护. #includ ...

  2. csp-s模拟测试61砖块, 数字,甜圈题解

    题面:https://www.cnblogs.com/Juve/articles/11626350.html 砖块: 直接模拟即可,map统计被覆盖的次数 #include<iostream&g ...

  3. csp-s模拟测试56Merchant, Equation,Rectangle题解

    题面:https://www.cnblogs.com/Juve/articles/11619002.html merchant: 二分答案,贪心选前m大的 但是用sort复杂度不优,会T掉 我们只是找 ...

  4. csp-s模拟测试54x,y,z题解

    题面:https://www.cnblogs.com/Juve/articles/11606834.html x: 并差集,把不能分到两个集合里的元素和并到一起,设连通块个数为cnt,则答案为:$2^ ...

  5. csp-s模拟测试53u,v,w题解

    题面:https://www.cnblogs.com/Juve/articles/11602450.html u: 用差分优化修改 二维差分:给(x1,y1),(x2,y2)加上s: $d[x1][y ...

  6. csp-s模拟测试51(b)attack,tree题解

    题面:https://www.cnblogs.com/Juve/articles/11598286.html attack: 支配树裸题? 看一下支配树是什么: 问题:我们有一个有向图(可以有环),定 ...

  7. csp-s模拟测试99

    csp-s模拟测试99 九九归一直接爆炸. $T1$一眼板子. $T2$一眼语文题(语文的唯一一次$120+$是给模拟出来的可知我的语文能力). $T3$一眼普及题. ?? Hours Later 板 ...

  8. csp-s模拟测试98

    csp-s模拟测试98 $T1$??不是我吹我轻松手玩20*20.$T2$装鸭好像挺可做?$T3$性质数据挺多提示很明显? $One$ $Hour$ $Later$ 这$T1$什么傻逼题真$jb$难调 ...

  9. csp-s模拟测试97

    csp-s模拟测试97 猿型毕露.水题一眼秒,火题切不动,还是太菜了. $T1$看了一会儿感觉$woc$期望题$T1??$假的吧??. $T2$秒. $T3$什么玩意儿. 40 01:24:46 00 ...

随机推荐

  1. Unity 之事件系统

    游戏开发过程中事件是非常多的,可以通过 Messenger 事件系统来解藕,用法如下: 使用方法 例子:在按下拍照按钮后通知刷新好友面板 步骤1.添加事件字段,该字段具有唯一性 在MessangerE ...

  2. VIM 配色方案,先保存一下

    https://github.com/chriskempson/tomorrow-theme http://ethanschoonover.com/solarized http://ethanscho ...

  3. nodejs--express安装失败的原因

    1.检查更新所有的npm ,jade,或者ejs. 2.在用jade或ejs也是有区别的,jade适合个人秀,ejs更实用与商务. 3.express在4.+之后的版本都分离了,推荐用3.+的版本稳定 ...

  4. 第一周课堂笔记1th

    1.      计算机基本组成 CPU:中央处理器,人的大脑 内存:临时存储数据       (特点:断电即消失,容量小12G 24G) 硬盘:永久存储数据(特点:断电不消失容量大,500G 1T) ...

  5. myeclipse问题

    eclipse使用过程中发现汉字太小,几乎不可辨识. 更改办法:eclipse界面依次选择“window”–“preference”–“general”–“appearance”–“color and ...

  6. 7_API调用

    0 查看 kifastcallentry 里面具体怎么调用 首先是 切换了 fs 为kpcr的选择子 然后 构造了 一个trap frame(保存3环-->0环 切换的上下文:如果0环不使用就没 ...

  7. JS事件 鼠标经过事件(onmouseover)鼠标经过事件,当鼠标移到一个对象上时,该对象就触发onmouseover事件,并执行onmouseover事件调用的程序。

    鼠标经过事件(onmouseover) 鼠标经过事件,当鼠标移到一个对象上时,该对象就触发onmouseover事件,并执行onmouseover事件调用的程序. 现实鼠标经过"确定&quo ...

  8. npm 安装vue 报错Failed at the chromedriver@2.46.0 install script 'node install.js'

    原因一般是下载源被封了,我们连接淘宝的下载源下载: npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/d ...

  9. postman报InvalidArgumentException

    解决方案:

  10. 【JZOJ6294】动态数点

    description analysis 这题出的失败在只卡正解不卡暴力 比较好想的方法是枚举约数,向两边二分,但是这个不满足二分性 首先用\(ST\)表维护区间的\(\gcd\),不用线段树,这样查 ...