03 2024 档案
摘要:原题链接 题解 分层图最短路模板题 code #include<bits/stdc++.h> using namespace std; struct Node{ int way,key,value; bool operator >(const Node &a)const{ return value>
阅读全文
摘要:原题链接 题解 Dijkstra算法+反向索引堆优化 code #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=2e5+5; const int M=1e5+5; const ll MAX=
阅读全文
摘要:题解 Dijkstra算法的应用,我这里采用了 堆结构优化+反向索引堆优化 最大化的优化了时间复杂度。题解区的复杂度是O(mlogm)而我优化后达到了O((n+m)logn)即复杂度和点的个数相关,而非边的条数。 code #include<bits/stdc++.h> using namespac
阅读全文
摘要:题解 首先根据b1⊕b2=a1,b2⊕b3=a2...bj⊕bj+1=aj 我们不难得出b1⊕bj+1=a1⊕a2⊕a3....⊕aj 因此我们只需要确定b1的值就能够确定其余所有bi的值,而题目又要求我们的b处于0~n-1范围内,这实际上实在寻找一个 b1 使得异或出来的所有值越小越好,所以我
阅读全文
摘要:原题链接 题解:拓扑排序的拓展应用 由拓扑排序可以得出一种排名方式,而要判断是否有多种排名方式时只需要在每个结点设置入度结点判定即可(由相同结点删去后导致入度为零的结点个数)。 code #include<bits/stdc++.h> using namespace std; const int N
阅读全文
摘要:题解:模拟+去重 每一次扔球都将所有可能性加入队列,并设为一层;然后将一层的可能性挨个出列并进行 ((qj+ri−1) mod n+1),((qj−ri−1+n) mod n+1)操作,然后去重后入列。 code #include<bits/stdc++.h> using namespace std
阅读全文
摘要:题解 遇到map时,sum++;遇到pie时,sum++。 特殊情况遇到mapie时,sum--(因为map,pie分别加了一次,但是该子串只需要去掉p即可) code #include<bits/stdc++.h> using namespace std; const int N=2e5+5; i
阅读全文
摘要:题解 由于a1的值只能通过对a2的操作进行消除,所以我们可以先根据a1的值迭代出a2,a3的值,然后此时的a2,只能通过a3的操作进行消除.....以此类推,如果其中发现有ai的值<0就输出NO。 code #include<bits/stdc++.h> using namespace std; c
阅读全文
摘要:题解 简单的二分应用,对于每个bi我们只需找到最大的ci使得bi+ci<=target即可 code #include<bits/stdc++.h> using namespace std; int a[105],b[105]; int main(){ // freopen("input.txt",
阅读全文
摘要:原题链接 题解 最小生成树的应用。这道题多转了一个弯,这道题其实多了一个结点(代表一个虚拟水井),每块田打井的费用可以过渡到从虚拟水井运水的费用,然后再套用最小生成树的模板即可。 code #include<bits/stdc++.h> using namespace std; typedef lo
阅读全文
摘要:原题链接 bfs的深度用法。这题最坑的我觉得是输入输出格式的处理(一不小心就容易格式错误)调了好几个小时..... 这里放一组udebug数据 SAMPLE 3 1 N 3 3 1 1 WL NR * 1 2 WL NR ER WF * 1 3 NL ER * 2 1 SL WR NF * 2 2
阅读全文
摘要:原题链接 法一:运用结论 最小生成树也是最小瓶颈树,但最小瓶颈树不一定是最小生成树。 所以这题我们可以直接套用最小生成树模板 #include<bits/stdc++.h> using namespace std; struct G{ int from,to,value; }; G a[8005];
阅读全文
摘要:原题链接 最小生成数模板(K算法) code #include<bits/stdc++.h> using namespace std; const int N=2e5+5; const int M=5005; int father[M]; struct G{ int from,to,value; }
阅读全文