摘要:
采用前缀和思想,用二分查找寻找区间,时间复杂度O(n+nlogn) c++ include define maxn 2000000 using namespace std; long long arr[maxn+1]; long long brr[maxn+1]; int main() { brr[ 阅读全文
摘要:
具体解法是:对队首的某一状态,枚举每一个开关灯操作,记录到达这一新状态的步数(也就是老状态 + 1),若是最终答案,输出,若不是,压入队列。采用结构体记录每个节点,包含当前状态和步数。 c++ include using namespace std; typedef struct{ int stat 阅读全文
摘要:
[toc] A题 基本思路: 假设n个学生开始字母相同,则分成n/2和n n/2两对的配对数最少 c++ include using namespace std; int main() { int n;cin n;int a[26]={0}; for(int i=0;i s; a[s[0] 'a'] 阅读全文
摘要:
```c++ include using namespace std; typedef struct{ int l,r,w; }Node; Node nodes[1000000]={0,0,0}; int x,y,ans,mod,single; void build(int l,int r,int 阅读全文
摘要:
1. 朴素解法,复杂度On2,只能过一半的点。 c++ include using namespace std; typedef struct{ int num; int len; int dlen; }Missile; Missile miss[100010]; int cnt=0,n=1,max 阅读全文
摘要:
s1和s2是两个字符串,小明想知道这两个字符串里最长的公共长度。 s1,s2长度小于5000。 所谓公共长度: 去掉任意长度的字符后,对于子序列s1[i..j]和子序列s2[m..n],(j i)=(n m),且s1[i+k]=s2[m+k] (0 include include include i 阅读全文