https://ac.nowcoder.com/acm/contest/881/E 从dp的角度来看是比较正常的.无后效性来源于前面只要的合法的方案分配,那么对后面造成的影响就只有A,B的数目. 从贪心的角度看,前n个A必定是给AB用的,前m个B必定是给BA用的.否则假如有一个BA用了一个前n个A里的A,那么可以把这个A和后面的某个A互换所在的组. --- dp参考JHSeng大佬的题解. 设 \(dp[i][j]\) 表示放置 \(i\) 个A,放置 \(j\) 个B的合法方案数.显然 \(d…
传送门 知识点:卡特兰数/动态规划 法一:动态规划 由题意易知字符串的任何一个前缀都满足\(cnt(A) - cnt(B) \le n , cnt(B)-cnt(A)\le m\) \(d[i][j]\) 表示前\(i\) 个字符,有 \(j\) 个\(A\) ,有\(i-j\) 个\(B\) 的方案数 \(d[0][0] = 1,d[2*n+2*m][n+m] 为答案\) 当\(j-(i-j)\le n,(i-j)-j\le m\) 时,\(d[i][j] = d[i-1][j] + d[i-…
给你n个点,第i个点在的位置为(xi,yi),有两个属性值(ai,bi).现在让你把这n个点划分为A和B两个部分,使得最后不存在i∈A和j∈B,使得xi>=xj且yi<=yj.然后对于所有的划分方法,找到并输出最大和 现在的疑问点在于为什么要多加一个高度为0的虚拟节点(因为要考虑全是A集合的) #include <bits/stdc++.h> #define ll long long #define inf 0x3f3f3f3f using namespace std; const…
题意:求Σfi^m%p. zoj上p是1e9+7,牛客是1e9:  对于这两个,分别有不同的做法. 前者利用公式,公式里面有sqrt(5),我们只需要二次剩余求即可.     后者mod=1e9,5才mod下没有二次剩余,所以不能这么做了.可以分解mod,然后利用循环节搞. zoj: #include <bits/stdc++.h> using namespace std; typedef long long LL; ; ; LL fac[N],A[N],B[N]; void Init() {…
链接:https://ac.nowcoder.com/acm/contest/881/A来源:牛客网 题目描述 Two arrays u and v each with m distinct elements are called equivalent if and only if RMQ(u,l,r)=RMQ(v,l,r)RMQ(u,l,r)=RMQ(v,l,r) for all 1≤l≤r≤m1≤l≤r≤mwhere RMQ(w,l,r)RMQ(w,l,r) denotes the inde…
链接:https://ac.nowcoder.com/acm/contest/881/B 来源:牛客网 Integration 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048576K 64bit IO Format: %lld 题目描述 Bobo knows that ∫ ∞ 0 1 1 x 2 d x = π 2 . ∫0∞11+x2 dx=π2. Given n distinct positive integers a 1 , a 2 , -…
链接:https://ac.nowcoder.com/acm/contest/881/A 来源:牛客网 Equivalent Prefixes 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048576K 64bit IO Format: %lld 题目描述 Two arrays u and v each with m distinct elements are called equivalent if and only if R M Q ( u ,…
链接:https://ac.nowcoder.com/acm/contest/882/F来源:牛客网 Given 2N people, you need to assign each of them into either red team or white team such that each team consists of exactly N people and the total competitive value is maximized. Total competitive va…
链接:https://ac.nowcoder.com/acm/contest/881/A来源:牛客网 Two arrays u and v each with m distinct elements are called equivalent if and only if RMQ(u,l,r)=RMQ(v,l,r)RMQ(u,l,r)=RMQ(v,l,r) for all 1≤l≤r≤m1≤l≤r≤m where RMQ(w,l,r)RMQ(w,l,r) denotes the index of…
链接:https://ac.nowcoder.com/acm/contest/889/D来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 Amy asks Mr. B  problem D. Please help Mr. B to solve the following problem. Amy wants to crack Merkle–Hellman knapsack…