死活TLE....求助
update 4.3 23:08 求助了tls之后终于过了...分治里次数界写崩了...r-l+1就行...分治的做法很神奇!本题的限制在于操作类型与权值相对大小有关,而用[l,mid]更新[mid+1,r]正好适应了本题的要求
#include#include #include #include #include using namespace std;typedef long long ll;const int N = (1<<17) + 5;const double PI = acos(-1.0);inline int read() { char c=getchar();int x=0,f=1; while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();} return x*f;} struct meow{ double x, y; meow(double x=0, double y=0):x(x), y(y){}};meow operator + (meow a, meow b) {return meow(a.x + b.x, a.y + b.y);}meow operator - (meow a, meow b) {return meow(a.x - b.x, a.y - b.y);}meow operator * (meow a, meow b) {return meow(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x);}meow conj(meow a) {return meow(a.x, -a.y);}typedef meow cd; namespace fft { int maxlen = 1<<17, rev[N]; cd omega[N], omegaInv[N]; void init() { for(int i=0; i >1; for(cd *p = a; p != a+n; p += l) for(int k=0; k >1]>>1) | ((i&1)<<(k-1)); dft(a, n, 1); dft(b, n, 1); for(int i=0; i >1; int n = 1, lim = r-l+1; if(r-l < 200) { for(int i=l; i<=mid; i++) if(a[i] || b[i]) for(int j=mid+1; j<=r; j++) c[i+j] += (ll) a[i] * b[j], c[j-i] += (ll) a[j] * b[i]; } else { while(n < lim) n<<=1; for(int i=0; i