摘要:
题目链接:https://www.luogu.org/problemnew/show/P3385 SPFA判负环。 这个题必须卡一卡才过得去。 按理说对于一个负环点应当是入队 n次。 但是这个题数据不是很友好qwq 所以我们把入队次数变成 = (n/4)次。 到考试的时候你说是写 n 还是 (n/4 阅读全文
摘要:
题解报告:https://www.luogu.org/problemnew/show/P2341 我们把图中的强连通分量缩点,然后只有出度为0的牛是受欢迎的,这样如果出度为0的牛只有一个,说明受所有牛欢迎。否则出度为0只是受一些牛欢迎。 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P2863 求强连通分量大小 自己单个点的 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P2002 缩点把原图变为DAG,再在DAG上判断找入度为0的点的个数。 注意一点出度为0的点的个数不等于入度为0的点。 include include include include include using 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P2169 tarjan缩点 + SPFA 缩完点之后加边注意别写错。 也可以不用建两个图,可以在一张图上判断是否强连通再SPFA. include include include include include 阅读全文
摘要:
无优化:500ms deque优化:400ms include include include include include using namespace std; const int maxn = 550000; const int inf = 0x7fffffff; int dis[maxn 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P2939 本来说是双倍经验题,跟飞行路线一样的,结果我飞行路线拿deque优化SPFA过了这里过不了了。 所以多学一种优先队列优化。 include include include include include 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P4568 卡了一晚上,算是分层图最短路的模板。注意卡SPFA,所以我写了个SLF优化。 同时 AC400祭!~ include include include include include define ri 阅读全文
摘要:
题目链接:http://noi.openjudge.cn/ch0206/9277/ ... include include include include using namespace std; struct Matrix{ long long m[3][3]; }A,E,ans; long lo 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P4231 诶 我很迷啊..这跟树状数组有什么关系啊...拿二阶差分数组过了..? 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P2880 是你逼我用ST表的啊qaq include include include include using namespace std; const int maxn = 500001; int minst 阅读全文
摘要:
王强怎么这么强啊 王强太强了 二维树状数组 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P1774 归并排序求逆序对。 include define livelove long long using namespace std; const int maxn = 600001; livelove a[ 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P1462 记住HP=0也叫死。 include include include include include using namespace std; const int maxn = 5000001; con 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P3808 include include include include include using namespace std; const int maxn = 1000010; int n, trie[ma 阅读全文
摘要:
$Scapegoat$_$Tree$ ——(替罪羊树) ——识替罪羊树之算法乃吾生之幸也! $First$.引子: 知乎上面有个问题问最优雅的算法是什么,我觉得 暴力即是优雅。 当然这里说的暴力并不是指那种不加以思考的无脑的暴力,而是说用繁琐而技巧性的工作可以实现的事,我用看似简单的思想和方法,也可 阅读全文
摘要:
``` #include #include #include #include #define alpha 0.8 #define maxn 2000001 #define ri register #define il inline using namespace std; struct scapegoat{ int son[2], val, valid, total;//valid(有... 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P1801 替罪羊树吼啊! include include include include define il inline using namespace std; const int maxn = 200000 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P2590 我想学树剖QAQ include include include include using namespace std; const int maxn = 31000; int fa[maxn], d 阅读全文
摘要:
题目链接:https://www.luogu.org/problemnew/show/P3398 辣鸡树剖1300ms 倍增大法吼啊 阅读全文