版本比较
省选日记 Day36 - Day40
正文
增加 18 行删除 18 行
265 行未改动全部展开26626726826927027027127227327417 行未改动29229329429529629629729829930030130230330330430530630737 行未改动34534634734834934935035135235335335435535635721 行未改动37938038138238338338438538638717 行未改动40540640740840940941041141241335 行未改动44945045145245345345445545645718 行未改动47647747847948048048148248348348448548648719 行未改动50750850951051151151251351451536 行未改动55255355455555655655755855956041 行未改动602603604605606606607608609610611612612613614615616617618619620620621622623624625626626627628629630150 行未改动全部展开78178278378478578578678778878931 行未改动82182282382482582582682782882969 行未改动265 行未改动全部展开 } long double Len, StanB, StanK, StanX1, StanY1, StanX2, StanY2; StanX1 = RDsg(), StanY1 = RDsg(); StanX2 = RDsg(), StanY2 = RDsg(); if(StanX1 > StanX2) swap(StanX1, StanX2), swap(StanY1, StanY2); if(StanX1 > StanX2) swap(StanX1, StanX2), swap(StanY1, StanY2); Len = sqrt(Squ(StanX2 - StanX1) + Squ(StanY2 - StanY1)); Sin = (StanY2 - StanY1) / Len; Cos = (StanX2 - StanX1) / Len; StanK = (StanY2 - StanY1) / (StanX2 - StanX1);17 行未改动 } else Tot[++n] = {DownR[j].Pos, DownR[j].Val + UpR[i].Val}, ++j, ++i; } long double Cur(0); for (unsigned i(1), j(1); i < n; ++i) { while ((j < n) && (Tot[j + 1].Pos - Tot[i].Pos <= L)) while ((j < n) && (Tot[j + 1].Pos - Tot[i].Pos <= L)) Cur += Tot[j].Val * (Tot[j + 1].Pos - Tot[j].Pos), ++j; Ans = max(Ans, Cur + (L - Tot[j].Pos + Tot[i].Pos) * Tot[j].Val); Cur -= Tot[i].Val * (Tot[i + 1].Pos - Tot[i].Pos); } Cur = 0; for (unsigned i(n), j(n); j > 1; --j) { while ((i > 1) && (Tot[j].Pos - Tot[i - 1].Pos <= L)) while ((i > 1) && (Tot[j].Pos - Tot[i - 1].Pos <= L)) Cur += Tot[i - 1].Val * (Tot[i].Pos - Tot[i - 1].Pos), --i; Ans = max(Ans, Cur + (L - Tot[j].Pos + Tot[i].Pos) * Tot[i - 1].Val); Cur -= Tot[j - 1].Val * (Tot[j].Pos - Tot[j - 1].Pos); }37 行未改动inline void Find(unsigned Pos, unsigned Len) { A = B = Pos; B = Pos + 1; for (unsigned i(17); ~i; --i) if((B + (1 << i) - 1 <= n) && (ST[i][B] >= Len)) if((B + (1 << i) - 1 <= n) && (ST[i][B] >= Len)) B += (1 << i); --B; A = Pos; for (unsigned i(17); ~i; --i) for (unsigned i(17); ~i; --i) if((A > (1 << i)) && (ST[i][A - (1 << i)] >= Len)) A -= (1 << i); --A; if(ST[0][Pos] < Len) A = Pos;}21 行未改动 for (unsigned i(1); i <= n; ++i) SA[Bucket[RK[Tmp[i]]]--] = Tmp[i]; memcpy(Tmp, RK, (n + 1) << 3); RK[SA[1]] = 1, Cnt = 1; for (unsigned i(2); i <= n; ++i) if((Tmp[SA[i]] ^ Tmp[SA[i - 1]]) || (Tmp[SA[i] + Cons] ^ Tmp[SA[i - 1] + Cons])) if((Tmp[SA[i]] ^ Tmp[SA[i - 1]]) || (Tmp[SA[i] + Cons] ^ Tmp[SA[i - 1] + Cons])) RK[SA[i]] = ++Cnt; else RK[SA[i]] = Cnt; Cons <<= 1, BucSize = Cnt; }17 行未改动```cppstruct String { Node* Nd; unsigned Len, L; inline const char operator< (const String& x) const { inline const char operator< (const String& x) const { return (Len ^ x.Len) ? (Len > x.Len) : (Su_Ar.RK[L] < Su_Ar.RK[x.L]); } inline void Input() { L = RD(), Len = RD() - L + 1;}}TpA[200005], TpB[200005];35 行未改动 inline void Insert(unsigned L, unsigned R, Node *x, String **List, unsigned Len); inline void Link(unsigned L, unsigned R);}N[5000005], *Ver[200005], *From, *NB, *CntN(N);struct String { /*前面已经给出*/ };inline void Node::LinkTo(Node* x) { inline void Node::LinkTo(Node* x) { E.push_back(x), ++(x->Idg);}inline void Node::Link(unsigned L, unsigned R) { if(A <= L && R <= B) {From->LinkTo(this); return;}18 行未改动unsigned m, ma, mb;inline void Clr() { memset(N, 0, (m + 1) * sizeof(Node)); memset(Ver, 0, (n + 2) << 3); N->E.push_back(N), N->E.push_back(N); N->E.push_back(N), N->E.push_back(N); CntN = N, Ans = 0; memset(a, 0, n + 1); scanf("%s", a + 1); scanf("%s", a + 1); n = strlen(a + 1); Su_Ar.Init(a);}signed main() {19 行未改动 Su_Ar.Find(Su_Ar.RK[TpB[i].L], TpB[i].Len); if(Ver[TpB[i].Len]) Ver[TpB[i].Len]->Link(1, n); } m = RD(); for (unsigned i(1); i <= m; ++i) for (unsigned i(1); i <= m; ++i) A = RD(), B = RD(), N[A].LinkTo(NB + B); m = CntN - N + mb; Node* Que[m + 1], **Hd(Que), **Tl(Que); for (Node* i(N + m); i > N; --i) if(!(i->Idg)) *(++Tl) = i;36 行未改动
为了求这个式子, 仍然是移动 $\sum$ 符号.
$$\sum_{a = 1}^A\lfloor \frac Aa \rfloor \sum_{b = 1}^B\lfloor \frac Bb \rfloor \sum_{c = 1}^C\lfloor \frac Cc \rfloor [(a, b) = (a, c) = (b, c) = 1] \sum_{a = 1}^A\lfloor \frac Aa \rfloor \sum_{b = 1}^B\lfloor \frac Bb \rfloor \sum_{c = 1}^C\lfloor \frac Cc \rfloor [(a, b) = (a, c) = (b, c) = 1]$$
然后我们就得到了极为先进的 $O(n^3)$ 算法, 还是 $0'$.
41 行未改动unsigned a[200005][2], m, n;unsigned C, D, t;unsigned Cnt(0), Ans(0), Tmp(0);struct Node { vector<Node*> E; vector<Node*> E; unsigned Dgr, Num; inline const char operator< (const Node& x) { return Dgr < x.Dgr; }}N[100005], *List[100005], *A, *B;signed main() { n = RD(), m = RD(); for (unsigned i(1); i <= n; ++i) N[i].Num = i; for (unsigned i(1); i <= n; ++i) N[i].Num = i; for (unsigned i(1); i <= m; ++i) ++(N[a[i][0] = RD()].Dgr), ++(N[a[i][1] = RD()].Dgr); sort(N + 1, N + n + 1); for (unsigned i(1); i <= n; ++i) List[N[i].Num] = N + i; for (unsigned i(1); i <= m; ++i) { A = List[a[i][0]], B = List[a[i][1]]; if(A < B) A->E.push_back(B); else B->E.push_back(A); else B->E.push_back(A); } for (unsigned i(1); i <= n; ++i) sort(N[i].E.begin(), N[i].E.end()); for (unsigned i(1); i <= n; ++i) { unsigned Bot(0); for (auto j:N[i].E) { unsigned Lim(N[i].E.size() - 1), l(Bot++); unsigned Lim(N[i].E.size() - 1), l(Bot++); for (auto k:j->E) { while (N[i].E[l] < k && l < Lim) ++l; if(N[i].E[l] == k) ++Ans; }150 行未改动全部展开
发现可以不用真的去给那些数字减 $1$, 只要统计每个数后面比它小的数字数量即可. 果断使用树状数组维护.
```cpp#define Lbt(x) (((~(x))+1)&(x)) #define Lbt(x) (((~(x))+1)&(x))const unsigned long long Mod(998244353);unsigned a[1000005], Tr[1000005], n;unsigned long long Fac(1), Ans(1);inline void Add(unsigned x) {while(x <= n) ++Tr[x], x += Lbt(x);}31 行未改动unsigned A, B, C, D, t;unsigned Cnt(0), Ans(0), Tmp(0);struct Node { Node* LS, * RS; unsigned Val; unsigned Val;}N[10000005], *Stack[10000005], **STop(Stack), *Root(NULL);inline void Print() { for (unsigned i(1); i <= n; ++i) printf("%u LS %u RS %u\n", i, N[i].LS - N, N[i].RS - N);69 行未改动