空题段长度即为单调队列长度区间 每次二分答案进行check即可 #include<bits/stdc++.h> using namespace std; ; const int inf=0x3f3f3f3f; int n,t,l,r,mid,ans; int a[N],q[N],f[N]; int head,tail; bool check(int mid){ memset(f,,sizeof f); memset(q,,sizeof q); head=tail=; ;i<=n;i++)…
Description Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't e…
Assignment Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 557 Accepted Submission(s): 280 Problem Description Tom owns a company and he is the boss. There are n staffs which are numbered fr…
单调队列存坐标 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #define R(a,b,c) for(register int a = (b); a <= (c); ++ a) #define nR(a,b,c) for(register int a = (b); a >= (c); --…
对作文库中的串建出广义SAM,然后显然可以二分答案,二分之后考虑暴力dp,设f[i]为前i位最长匹配长度,显然有f[i]=max(f[i-1],f[j]+i-j) (i-j>=l&&j+1~i能在作文库中匹配).在SAM上跑并记录匹配长度,单调队列优化dp即可. #include<bits/stdc++.h> using namespace std; #define ll long long #define N 2200010 char getc(){char c=get…