题面: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. RoHS

    RoHS是<电气.电子设备中限制使用某些有害物质指令>(the Restriction of the use of certain hazardous substances in elec ...

  2. linux下使用scp在服务器之间拷贝文件 (转载)

    CentOS, 本地服务器,ip: 192.168.1.111Ubuntu, 远程服务器,ip: 192.168.1.112 1.拷贝远程服务器的目录到本地服务器远程服务器192.168.1.112上 ...

  3. python的安装与版本共存与卸载

    目录 python3的安装 python3的下载 python3的安装 python3与python2共存 python3的卸载 @ python3的安装 python3的下载 打开网址:python ...

  4. 【收集+】DDR5 vs DDR4

    Advantages of Migrating to DDR5 DDR5 is the next evolution in DRAM, bringing a robust list of new fe ...

  5. LA 3263 /// 欧拉定理 oj21860

    题目大意: n个端点的一笔画 第n个和第1个重合 即一笔画必定是闭合曲线 输出平面被分成的区域数 欧拉定理 V+F-E=2 即 点数+面数-边数=2 (这里的面数包括了外部) #include < ...

  6. java 冒泡排序法、选择排序

    1.冒泡排序 /* * 冒泡排序 * 外层控制循环多少趟,内层控制每一趟的循环次数 */ public class Test08 { public static void main(String[] ...

  7. c++11 Thread库写多线程程序

    一个简单的使用线程的Demo c++11提供了一个新的头文件<thread>提供了对线程函数的支持的声明(其他数据保护相关的声明放在其他的头文件中,暂时先从thread头文件入手吧),写一 ...

  8. BZOJ2152 聪明可可 点分治

    题意传送门 思路:基本的点分治思路,num数组记录从u点开始路径长度分别为1或者2或者3的路径长度(取模3意义下),然后做一个简单的容斥就好了. 为了避免计数的麻烦,<u,u>这样的点单独 ...

  9. CSIC_716_20191104【流程控制语句】

    流程控制语句 if 语法结构 if 逻辑判断为真 : xxxxxx else: xxxxx while 语法结构  (continue.break) while 逻辑判断为真: xxxxxxx con ...

  10. leetcode-157周赛-5215黄金矿工

    题目描述: 方法一:dfs class Solution: def getMaximumGold(self, grid: List[List[int]]) -> int: maxx = 0 R, ...