摘要:
4N空间版 cpp include include using namespace std; const int SIZE=100010; int N, M, P; //P为模 inline long long read() { long long s=0, w=1; char ch=getchar 阅读全文
摘要:
WARNING 朴素SPFA的时间复杂度为$ke$,$k$在极端情况下会趋近于$n$,接近于Bellman Ford算法。这种极端情况并不罕见,在近几年的竞赛中这种恶意数据很多,如 的T1,SPFA死掉了。 所以,求最短路时,如果图没有负边权的话,建议使用队列优化的Dijkstra。 BFS_SPF 阅读全文
摘要:
```cpp //P2002解题思路: //先求SCC,缩点后,转换为DAG(有向无环图) //在DAG上统计入度为0的scc数量即可 //Tarjan时间复杂度:O(N+E),每个点和每条边刚好被访问一次,在空间和时间上比Kosaraju好一些。 include include include i 阅读全文
摘要:
```cpp //P2002解题思路: //先求SCC,缩点后,转换为DAG(有向无环图) //在DAG上统计入度为0的scc数量即可 //Kosaraju时间复杂度:O(N+E) //两次DFS,2N,图的转置E,共2N+E include include include include usin 阅读全文
摘要:
```cpp include include include include using namespace std; const int maxn=100010; struct edge{ int t; edge nxt; edge(int to, edge next){ t=to, nxt=ne 阅读全文
摘要:
模板1 cpp include include using namespace std; int n, m, c[500010]; inline int read(){ int s=0,w=1; char ch=getchar(); while(ch'9') { if(ch==' ')w= 1; c 阅读全文
摘要:
```cpp include include using namespace std; long long a[80010], b[80010], sum[80010], ans, now; long long n, opt, mod, minn, maxx, l, r, x, f; char ch 阅读全文
摘要:
```cpp include include include using namespace std; int N, M, a[100009], l, r, st[100009][20]; inline int read() { int s=0, w=1; char ch=getchar(); wh 阅读全文
摘要:
时间复杂度:dfs为 ,dfs过程中处理所有查询对为 ,总时间复杂度 cpp include include using namespace std; const int maxn=500010, maxm=500010; int N, M, S, tot, h[maxn], v[maxn], fa 阅读全文
摘要:
时间复杂度: dfs树,求st表(状态数组f):O(NlgN) 处理M个查询:O(MlgN) 总:O((M+N)lgN) cpp include include include using namespace std; const int maxn=500010; struct edge{ int 阅读全文